Skip to content

Commit

Permalink
Summer code cleaning.
Browse files Browse the repository at this point in the history
  • Loading branch information
python-bear committed Jan 29, 2024
1 parent 3131fd6 commit ee5bd56
Show file tree
Hide file tree
Showing 18 changed files with 17 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.hit.EntityHitResult;
import net.minecraft.world.World;
import net.pythonbear.tead.entity.TeadEntities;
import net.pythonbear.tead.init.TeadItems;

public class GrenadeProjectileEntity extends ThrownItemEntity {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ protected void onEntityHit(EntityHitResult entityHitResult) {
}

if (this.piercingKilledEntities == null) {
this.piercingKilledEntities = Lists.<Entity>newArrayListWithCapacity(5);
this.piercingKilledEntities = Lists.newArrayListWithCapacity(5);
}

if (this.piercedEntities.size() >= this.getPierceLevel() + 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected void onEntityHit(EntityHitResult entityHitResult) {
}

if (this.piercingKilledEntities == null) {
this.piercingKilledEntities = Lists.<Entity>newArrayListWithCapacity(5);
this.piercingKilledEntities = Lists.newArrayListWithCapacity(5);
}

if (this.piercedEntities.size() >= this.getPierceLevel() + 1) {
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/net/pythonbear/tead/init/CustomAttacking.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public static void attack(PlayerEntity user, Entity target, Hand hand, Float att
g *= h;
user.resetLastAttackedTicks();
if ((f *= 0.2f + h * h * 0.8f) > 0.0f || g > 0.0f) {
ItemStack itemStack;
Optional<Map<Enchantment, Integer>> optionalEnchantments =
Optional.ofNullable(EnchantmentHelper.get(user.getStackInHand(hand)));
Map<Enchantment, Integer> itemStackEnchantments = optionalEnchantments.orElse(Collections.emptyMap());
Expand All @@ -68,15 +67,15 @@ public static void attack(PlayerEntity user, Entity target, Hand hand, Float att
boolean bl3 = bl && user.fallDistance > 0.0f && !user.isOnGround() && !user.isClimbing() &&
!user.isTouchingWater() && !user.hasStatusEffect(StatusEffects.BLINDNESS) && !user.hasVehicle() &&
target instanceof LivingEntity;
boolean bl4 = bl3 = bl3 && !user.isSprinting();
bl3 = bl3 && !user.isSprinting();
if (bl3) {
f *= 1.5f;
}
f += g;
boolean bl42 = false;
double d = user.horizontalSpeed - user.prevHorizontalSpeed;
if (bl && !bl3 && !bl2 && user.isOnGround() && d < (double)user.getMovementSpeed() &&
(itemStack = user.getStackInHand(hand)).getItem() instanceof SwordItem) {
user.getStackInHand(hand).getItem() instanceof SwordItem) {
bl42 = true;
}
float j = 0.0f;
Expand Down
9 changes: 3 additions & 6 deletions src/main/java/net/pythonbear/tead/item/BoneBowItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,10 @@ public boolean canRepair(ItemStack stack, ItemStack ingredient) {

@Override
public void onStoppedUsing(ItemStack stack, World world, LivingEntity user, int remainingUseTicks) {
boolean bl2;
int i;
float f;
if (!(user instanceof PlayerEntity)) {
if (!(user instanceof PlayerEntity playerEntity)) {
return;
}
PlayerEntity playerEntity = (PlayerEntity)user;
boolean bl = playerEntity.getAbilities().creativeMode || EnchantmentHelper.getLevel(Enchantments.INFINITY, stack) > 0;
ItemStack itemStack = playerEntity.getProjectileType(stack);
if (itemStack.isEmpty() && !bl) {
Expand All @@ -59,10 +56,10 @@ public void onStoppedUsing(ItemStack stack, World world, LivingEntity user, int
if (itemStack.isEmpty()) {
itemStack = new ItemStack(Items.ARROW);
}
if ((double)(f = BowItem.getPullProgress(i = this.getMaxUseTime(stack) - remainingUseTicks)) < 0.1) {
if ((double)(f = BowItem.getPullProgress(this.getMaxUseTime(stack) - remainingUseTicks)) < 0.1) {
return;
}
boolean bl3 = bl2 = bl && itemStack.isOf(Items.ARROW);
boolean bl2 = bl && itemStack.isOf(Items.ARROW);
if (!world.isClient) {
int k;
int j;
Expand Down
9 changes: 2 additions & 7 deletions src/main/java/net/pythonbear/tead/item/FireboltThrower.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.nbt.NbtList;
import net.minecraft.registry.tag.ItemTags;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
Expand All @@ -29,14 +28,12 @@

import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;

public class FireboltThrower extends CrossbowItem {
private boolean charged = false;
private boolean loaded = false;
private static final String CHARGED_PROJECTILES_KEY = "ChargedProjectiles";
private static final String CHARGED_KEY = "Charged";
public static final Predicate<ItemStack> BOW_PROJECTILES = stack -> stack.isIn(ItemTags.ARROWS);

public FireboltThrower(Settings settings) {
super(settings);
Expand Down Expand Up @@ -106,9 +103,8 @@ public static void shootAll(World world, LivingEntity entity, Hand hand, ItemSta
List<ItemStack> list = FireboltThrower.getProjectiles(stack);
float[] fs = FireboltThrower.getSoundPitches(entity.getRandom());
for (int i = 0; i < list.size(); ++i) {
boolean bl;
ItemStack itemStack = list.get(i);
boolean bl2 = bl = entity instanceof PlayerEntity && ((PlayerEntity)entity).getAbilities().creativeMode;
boolean bl = entity instanceof PlayerEntity && ((PlayerEntity)entity).getAbilities().creativeMode;
if (itemStack.isEmpty()) continue;
if (i == 0) {
FireboltThrower.shoot(world, entity, hand, stack, itemStack, fs[i], bl, speed, divergence,
Expand Down Expand Up @@ -178,8 +174,7 @@ private static PersistentProjectileEntity createArrow(World world, LivingEntity
}

private static void postShoot(World world, LivingEntity entity, ItemStack stack) {
if (entity instanceof ServerPlayerEntity) {
ServerPlayerEntity serverPlayerEntity = (ServerPlayerEntity)entity;
if (entity instanceof ServerPlayerEntity serverPlayerEntity) {
if (!world.isClient) {
Criteria.SHOT_CROSSBOW.trigger(serverPlayerEntity, stack);
}
Expand Down
11 changes: 1 addition & 10 deletions src/main/java/net/pythonbear/tead/item/LongBowItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import net.minecraft.sound.SoundEvents;
import net.minecraft.stat.Stats;
import net.minecraft.world.World;
import net.pythonbear.tead.Tead;

public class LongBowItem extends BowItem implements Vanishable {
public static final int TICKS_PER_SECOND = 1;
Expand All @@ -24,11 +23,9 @@ public LongBowItem(Settings settings) {
public static float getPullProgress(int useTicks) {
float f = (float)useTicks / TICKS_PER_SECOND;
f = (f * f + f * 2.0F) / 700;
Tead.LOGGER.info("progress1: " + f);
if (f > 1.0F) {
f = 1.0F;
}
Tead.LOGGER.info("progress2: " + f);
return f;
}

Expand All @@ -51,11 +48,6 @@ public int getRange() {
return RANGE;
}

@Override
public int getMaxUseTime(ItemStack stack) {
return 72000;
}

@Override
public boolean canRepair(ItemStack stack, ItemStack ingredient) {
return ingredient == Items.STICK.getDefaultStack() || ingredient == Items.STRING.getDefaultStack() ||
Expand All @@ -64,7 +56,6 @@ public boolean canRepair(ItemStack stack, ItemStack ingredient) {

@Override
public void onStoppedUsing(ItemStack stack, World world, LivingEntity user, int remainingUseTicks) {
boolean bl2;
float f;
if (!(user instanceof PlayerEntity playerEntity)) {
return;
Expand All @@ -81,7 +72,7 @@ public void onStoppedUsing(ItemStack stack, World world, LivingEntity user, int
if ((double)(f = LongBowItem.getPullProgress(this.getMaxUseTime(stack) - remainingUseTicks)) < 1) {
return;
}
boolean bl3 = bl2 = bl && itemStack.isOf(Items.ARROW);
boolean bl2 = bl && itemStack.isOf(Items.ARROW);
if (!world.isClient) {
int k;
int j;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/net/pythonbear/tead/item/ShortBowItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public boolean canRepair(ItemStack stack, ItemStack ingredient) {

@Override
public void onStoppedUsing(ItemStack stack, World world, LivingEntity user, int remainingUseTicks) {
boolean bl2;
float f;
if (!(user instanceof PlayerEntity playerEntity)) {
return;
Expand All @@ -56,7 +55,7 @@ public void onStoppedUsing(ItemStack stack, World world, LivingEntity user, int
if ((double)(f = ShortBowItem.getPullProgress(this.getMaxUseTime(stack) - remainingUseTicks)) < 0.1) {
return;
}
boolean bl3 = bl2 = bl && itemStack.isOf(Items.ARROW);
boolean bl2 = bl && itemStack.isOf(Items.ARROW);
if (!world.isClient) {
int k;
int j;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,10 @@ private boolean hasBootsOn(PlayerEntity player) {
private boolean hasCorrectArmorOn(PlayerEntity player) {
ItemStack bootsStack = player.getInventory().getArmorStack(0);

if (!(bootsStack.getItem() instanceof ArmorItem)) {
if (!(bootsStack.getItem() instanceof ArmorItem boots)) {
return false;
}

ArmorItem boots = (ArmorItem) bootsStack.getItem();

return boots.getMaterial() == TeadArmorMaterials.SWIFTNESS;
}

Expand Down
6 changes: 2 additions & 4 deletions src/main/java/net/pythonbear/tead/item/TrickBowItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public void usageTick(World world, LivingEntity user, ItemStack stack, int remai

@Override
public void onStoppedUsing(ItemStack stack, World world, LivingEntity user, int remainingUseTicks) {
boolean bl2;
float f;
if (!(user instanceof PlayerEntity playerEntity)) {
return;
Expand All @@ -79,7 +78,7 @@ public void onStoppedUsing(ItemStack stack, World world, LivingEntity user, int
if ((double)(f = TrickBowItem.getPullProgress(this.getMaxUseTime(stack) - remainingUseTicks)) < 0.1) {
return;
}
boolean bl3 = bl2 = bl && BOW_PROJECTILES.test(itemStack);
boolean bl2 = bl && BOW_PROJECTILES.test(itemStack);
if (!world.isClient) {
int k;
int j;
Expand Down Expand Up @@ -152,9 +151,8 @@ public void onStoppedUsing(ItemStack stack, World world, LivingEntity user, int

@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
boolean bl;
ItemStack itemStack = user.getStackInHand(hand);
boolean bl2 = bl = !getProjectileType(itemStack, user).isEmpty();
boolean bl = !getProjectileType(itemStack, user).isEmpty();
if (user.getAbilities().creativeMode || bl) {
user.setCurrentHand(hand);
return TypedActionResult.consume(itemStack);
Expand Down
9 changes: 3 additions & 6 deletions src/main/java/net/pythonbear/tead/item/WindBowItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,10 @@ public boolean canRepair(ItemStack stack, ItemStack ingredient) {

@Override
public void onStoppedUsing(ItemStack stack, World world, LivingEntity user, int remainingUseTicks) {
boolean bl2;
int i;
float f;
if (!(user instanceof PlayerEntity)) {
if (!(user instanceof PlayerEntity playerEntity)) {
return;
}
PlayerEntity playerEntity = (PlayerEntity)user;
boolean bl = playerEntity.getAbilities().creativeMode || EnchantmentHelper.getLevel(Enchantments.INFINITY,
stack) > 0;
ItemStack itemStack = playerEntity.getProjectileType(stack);
Expand All @@ -53,10 +50,10 @@ public void onStoppedUsing(ItemStack stack, World world, LivingEntity user, int
if (itemStack.isEmpty()) {
itemStack = new ItemStack(Items.ARROW);
}
if ((double)(f = BowItem.getPullProgress(i = this.getMaxUseTime(stack) - remainingUseTicks)) < 0.1) {
if ((double)(f = BowItem.getPullProgress(this.getMaxUseTime(stack) - remainingUseTicks)) < 0.1) {
return;
}
boolean bl3 = bl2 = bl && itemStack.isOf(Items.ARROW);
boolean bl2 = bl && itemStack.isOf(Items.ARROW);
if (!world.isClient) {
int k;
int j;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.mob.AbstractSkeletonEntity;
import net.minecraft.entity.mob.DrownedEntity;
import net.minecraft.entity.mob.SkeletonEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Hand;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.LocalDifficulty;
import net.pythonbear.tead.init.TeadItems;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.mob.DrownedEntity;
import net.minecraft.entity.mob.ZombieEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Hand;
import net.minecraft.util.math.random.Random;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import net.minecraft.entity.mob.PiglinEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Hand;
import net.minecraft.util.math.random.Random;
import net.pythonbear.tead.init.TeadItems;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
package net.pythonbear.tead.mixin;

import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.mob.PiglinEntity;
import net.minecraft.entity.mob.VindicatorEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.Hand;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.LocalDifficulty;
import net.pythonbear.tead.init.TeadItems;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(VindicatorEntity.class)
public class VindicatorInitEquipmentMixin {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@

import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.mob.WitherSkeletonEntity;
import net.minecraft.entity.mob.ZombieEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.Hand;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.Difficulty;
import net.minecraft.world.LocalDifficulty;
import net.pythonbear.tead.init.TeadItems;
import org.spongepowered.asm.mixin.Mixin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import net.minecraft.util.math.random.Random;
import net.minecraft.world.Difficulty;
import net.minecraft.world.LocalDifficulty;
import net.pythonbear.tead.Tead;
import net.pythonbear.tead.init.TeadItems;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -14,7 +13,6 @@

import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;

@Mixin(ZombieEntity.class)
public class ZombieInitEquipmentMixin {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
package net.pythonbear.tead.mixin;

import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.mob.PiglinEntity;
import net.minecraft.entity.mob.ZombieEntity;
import net.minecraft.entity.mob.ZombifiedPiglinEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Hand;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.Difficulty;
import net.minecraft.world.LocalDifficulty;
import net.pythonbear.tead.init.TeadItems;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(ZombifiedPiglinEntity.class)
public class ZombiePiglinInitEquipmentMixin {
Expand Down

0 comments on commit ee5bd56

Please sign in to comment.