Skip to content

Commit

Permalink
Fixed Neptunium Shovel & Pickaxe underwater speed boost applying to a…
Browse files Browse the repository at this point in the history
…ll players at once
  • Loading branch information
GirafiStudios committed Jan 12, 2020
1 parent 4b59fde commit eabfec9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import net.minecraft.client.renderer.color.ItemColors;
import net.minecraft.client.renderer.entity.TippedArrowRenderer;
import net.minecraft.client.renderer.tileentity.ChestTileEntityRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.entity.EntityType;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ public ResourceLocation getEntityTexture(@Nonnull AquaFishingBobberEntity fishHo
return BOBBER_VANILLA;
}

private static void renderPosTexture(IVertexBuilder builder, Matrix4f matrix4f, Matrix3f matrix3f, int i, float f, int x, int y, int z) {
builder.func_227888_a_(matrix4f, f - 0.5F, (float) x - 0.5F, 0.0F).func_225586_a_(255, 255, 255, 255).func_225583_a_((float) y, (float) z).func_227891_b_(OverlayTexture.field_229196_a_).func_227886_a_(i).func_227887_a_(matrix3f, 0.0F, 1.0F, 0.0F).endVertex();
private static void renderPosTexture(IVertexBuilder builder, Matrix4f matrix4f, Matrix3f matrix3f, int i, float x, int y, int u, int v) {
builder.func_227888_a_(matrix4f, x - 0.5F, (float) y - 0.5F, 0.0F).func_225586_a_(255, 255, 255, 255).func_225583_a_((float) u, (float) v).func_227891_b_(OverlayTexture.field_229196_a_).func_227886_a_(i).func_227887_a_(matrix3f, 0.0F, 1.0F, 0.0F).endVertex();
}

private static void renderPosTextureColor(IVertexBuilder builder, Matrix4f matrix4f, Matrix3f matrix3f, int i, float f, int x, int y, int z, float r, float g, float b) {
builder.func_227888_a_(matrix4f, f - 0.5F, (float) x - 0.5F, 0.0F).func_227885_a_(r, g, b, 1.0F).func_225583_a_((float) y, (float) z).func_227891_b_(OverlayTexture.field_229196_a_).func_227886_a_(i).func_227887_a_(matrix3f, 0.0F, 1.0F, 0.0F).endVertex();
private static void renderPosTextureColor(IVertexBuilder builder, Matrix4f matrix4f, Matrix3f matrix3f, int i, float x, int y, int u, int v, float r, float g, float b) {
builder.func_227888_a_(matrix4f, x - 0.5F, (float) y - 0.5F, 0.0F).func_227885_a_(r, g, b, 1.0F).func_225583_a_((float) u, (float) v).func_227891_b_(OverlayTexture.field_229196_a_).func_227886_a_(i).func_227887_a_(matrix3f, 0.0F, 1.0F, 0.0F).endVertex();
}

private static void renderPosColor(float x, float y, float z, IVertexBuilder builder, Matrix4f matrix4f, float f, float r, float g, float b) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.teammetallurgy.aquaculture.Aquaculture;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.IItemTier;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
Expand All @@ -13,22 +14,23 @@
import javax.annotation.Nonnull;

public class NeptuniumPickaxe extends PickaxeItem {
private boolean inWater = false;

public NeptuniumPickaxe(IItemTier tier, int attackDamage, float attackSpeed) {
super(tier, attackDamage, attackSpeed, new Item.Properties().group(Aquaculture.GROUP));
}

@Override
public void inventoryTick(@Nonnull ItemStack stack, World world, Entity entity, int i, boolean b) {
if (this.inWater != entity.areEyesInFluid(FluidTags.WATER)) {
this.inWater = entity.areEyesInFluid(FluidTags.WATER);
if (entity instanceof PlayerEntity && stack.getItem() == this) {
PlayerEntity player = (PlayerEntity) entity;
stack.getOrCreateTag().putBoolean("inWater", player.areEyesInFluid(FluidTags.WATER));
}
}

@Override
public float getDestroySpeed(@Nonnull ItemStack stack, BlockState state) {
float defaultSpeed = super.getDestroySpeed(stack, state);
return this.inWater ? (defaultSpeed * 5.0F) * 5.0F : defaultSpeed;
boolean isInWater = stack.hasTag() && stack.getTag() != null && stack.getTag().getBoolean("inWater");
return isInWater ? (defaultSpeed * 5.0F) * 5.0F : defaultSpeed;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.teammetallurgy.aquaculture.Aquaculture;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.IItemTier;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
Expand All @@ -13,22 +14,23 @@
import javax.annotation.Nonnull;

public class NeptuniumShovel extends ShovelItem {
private boolean inWater = false;

public NeptuniumShovel(IItemTier tier, float damage, float speed) {
super(tier, damage, speed, new Item.Properties().group(Aquaculture.GROUP));
}

@Override
public void inventoryTick(@Nonnull ItemStack stack, World world, Entity entity, int i, boolean b) {
if (this.inWater != entity.areEyesInFluid(FluidTags.WATER)) {
this.inWater = entity.areEyesInFluid(FluidTags.WATER);
public void inventoryTick(@Nonnull ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) {
if (entity instanceof PlayerEntity && stack.getItem() == this) {
PlayerEntity player = (PlayerEntity) entity;
stack.getOrCreateTag().putBoolean("inWater", player.areEyesInFluid(FluidTags.WATER));
}
}

@Override
public float getDestroySpeed(@Nonnull ItemStack stack, BlockState state) {
float defaultSpeed = super.getDestroySpeed(stack, state);
return this.inWater ? (defaultSpeed * 5.0F) * 5.0F : defaultSpeed;
boolean isInWater = stack.hasTag() && stack.getTag() != null && stack.getTag().getBoolean("inWater");
return isInWater ? (defaultSpeed * 5.0F) * 5.0F : defaultSpeed;
}
}

0 comments on commit eabfec9

Please sign in to comment.