Skip to content

Commit

Permalink
Added Spectral Arrow support, for Neptunium Bow
Browse files Browse the repository at this point in the history
  • Loading branch information
GirafiStudios committed May 10, 2021
1 parent f64d272 commit 6a2a36c
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScreenManager;
import net.minecraft.client.renderer.color.ItemColors;
import net.minecraft.client.renderer.entity.SpectralArrowRenderer;
import net.minecraft.client.renderer.entity.TippedArrowRenderer;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.player.PlayerEntity;
Expand Down Expand Up @@ -42,6 +43,7 @@ public static void setupClient() {
RenderingRegistry.registerEntityRenderingHandler(fish, (manager) -> new AquaFishRenderer(manager, fish.getRegistryName() != null && fish.getRegistryName().equals(new ResourceLocation(Aquaculture.MOD_ID, "jellyfish"))));
}
RenderingRegistry.registerEntityRenderingHandler(AquaEntities.WATER_ARROW, TippedArrowRenderer::new);
RenderingRegistry.registerEntityRenderingHandler(AquaEntities.SPECTRAL_WATER_ARROW, SpectralArrowRenderer::new);
RenderingRegistry.registerEntityRenderingHandler(AquaEntities.BOX_TURTLE, TurtleLandRenderer::new);
RenderingRegistry.registerEntityRenderingHandler(AquaEntities.ARRAU_TURTLE, TurtleLandRenderer::new);
RenderingRegistry.registerEntityRenderingHandler(AquaEntities.STARSHELL_TURTLE, TurtleLandRenderer::new);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.teammetallurgy.aquaculture.entity;

import com.teammetallurgy.aquaculture.init.AquaEntities;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.projectile.SpectralArrowEntity;
import net.minecraft.network.IPacket;
import net.minecraft.world.World;
import net.minecraftforge.fml.network.FMLPlayMessages;
import net.minecraftforge.fml.network.NetworkHooks;

import javax.annotation.Nonnull;

public class SpectralWaterArrowEntity extends SpectralArrowEntity {

public SpectralWaterArrowEntity(FMLPlayMessages.SpawnEntity spawnPacket, World world) {
super(world, 0, 0, 0);
}

public SpectralWaterArrowEntity(EntityType<? extends SpectralArrowEntity> arrow, World world) {
super(arrow, world);
}

public SpectralWaterArrowEntity(World world, LivingEntity livingEntity) {
super(world, livingEntity);
}

@Override
protected float getWaterDrag() {
return 1.0F;
}

@Override
@Nonnull
public EntityType<?> getType() {
return AquaEntities.SPECTRAL_WATER_ARROW;
}

@Override
@Nonnull
public IPacket<?> createSpawnPacket() {
return NetworkHooks.getEntitySpawningPacket(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.google.common.collect.Lists;
import com.teammetallurgy.aquaculture.Aquaculture;
import com.teammetallurgy.aquaculture.entity.AquaFishingBobberEntity;
import com.teammetallurgy.aquaculture.entity.SpectralWaterArrowEntity;
import com.teammetallurgy.aquaculture.entity.TurtleLandEntity;
import com.teammetallurgy.aquaculture.entity.WaterArrowEntity;
import com.teammetallurgy.aquaculture.misc.AquaConfig;
Expand Down Expand Up @@ -46,6 +47,9 @@ public class AquaEntities {
public static final EntityType<WaterArrowEntity> WATER_ARROW = register("water_arrow", EntityType.Builder.<WaterArrowEntity>create(WaterArrowEntity::new, EntityClassification.MISC)
.size(0.5F, 0.5F)
.setCustomClientFactory(WaterArrowEntity::new));
public static final EntityType<SpectralWaterArrowEntity> SPECTRAL_WATER_ARROW = register("spectral_water_arrow", EntityType.Builder.<SpectralWaterArrowEntity>create(SpectralWaterArrowEntity::new, EntityClassification.MISC)
.size(0.5F, 0.5F)
.setCustomClientFactory(SpectralWaterArrowEntity::new));
public static final EntityType<TurtleLandEntity> BOX_TURTLE = registerMob("box_turtle", 1, 2, 10, BiomeDictionary.Type.SWAMP, null, 0x7F8439, 0x5D612A,
EntityType.Builder.create(TurtleLandEntity::new, EntityClassification.CREATURE)
.size(0.5F, 0.25F));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.teammetallurgy.aquaculture.item.neptunium;

import com.teammetallurgy.aquaculture.Aquaculture;
import com.teammetallurgy.aquaculture.entity.SpectralWaterArrowEntity;
import com.teammetallurgy.aquaculture.entity.WaterArrowEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
Expand All @@ -26,6 +27,12 @@ public AbstractArrowEntity customArrow(@Nonnull AbstractArrowEntity arrowEntity)
return new WaterArrowEntity(arrowEntity.world, (LivingEntity) shooter);
}
}
if (arrowEntity.getType() == EntityType.SPECTRAL_ARROW) {
Entity shooter = arrowEntity.func_234616_v_();
if (shooter instanceof LivingEntity) {
return new SpectralWaterArrowEntity(arrowEntity.world, (LivingEntity) shooter);
}
}
return super.customArrow(arrowEntity);
}
}

0 comments on commit 6a2a36c

Please sign in to comment.