mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-26 06:42:56 +00:00
Formatting and code readability cleanup (#5467)
* First pass reformatting code to be more readable (common still not done) * Replace google common collect calls with Java calls where possible * Remove a bunch of unnecessary parenthesis leaving clarifying ones * Add some missing @Nonnull annotations * Fix checking wrong type * Remove unnecessary continue/return statements and simplify comparision check * Pass exception instead of directly printing stack trace * Work on cleaning up common, through config so far * Work on cleaning up common, through integration so far * Work on cleaning up common, through network so far * Work on cleaning up common, through tier so far * Remove empty constructors that get created by default anyways * Work on cleaning up common, through transmitters so far * Work on cleaning up common, through utils so far * Finish cleaning up spacing for common
This commit is contained in:
1 parent
91ef2a5c3d
commit
0d4b50908f
909 files changed
+6234
-15623
No files matched your search
@@ -28,12 +28,10 @@ public class CommonPlayerTickHandler {
|
||||
int x = MathHelper.floor(player.posX);
|
||||
int y = MathHelper.floor(player.posY - 0.01);
|
||||
int z = MathHelper.floor(player.posZ);
|
||||
|
||||
BlockPos pos = new BlockPos(x, y, z);
|
||||
IBlockState s = player.world.getBlockState(pos);
|
||||
AxisAlignedBB box = s.getBoundingBox(player.world, pos).offset(pos);
|
||||
AxisAlignedBB playerBox = player.getEntityBoundingBox();
|
||||
|
||||
return !s.getBlock().isAir(s, player.world, pos) && playerBox.offset(0, -0.01, 0).intersects(box);
|
||||
|
||||
}
|
||||
@@ -41,26 +39,21 @@ public class CommonPlayerTickHandler {
|
||||
public static boolean isGasMaskOn(EntityPlayer player) {
|
||||
ItemStack tank = player.inventory.armorInventory.get(2);
|
||||
ItemStack mask = player.inventory.armorInventory.get(3);
|
||||
|
||||
if (!tank.isEmpty() && !mask.isEmpty()) {
|
||||
if (tank.getItem() instanceof ItemScubaTank && mask.getItem() instanceof ItemGasMask) {
|
||||
ItemScubaTank scubaTank = (ItemScubaTank) tank.getItem();
|
||||
|
||||
if (scubaTank.getGas(tank) != null) {
|
||||
return scubaTank.getFlowing(tank);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isFlamethrowerOn(EntityPlayer player) {
|
||||
if (Mekanism.playerState.isFlamethrowerOn(player)) {
|
||||
return !player.inventory.getCurrentItem().isEmpty() && player.inventory.getCurrentItem()
|
||||
.getItem() instanceof ItemFlamethrower;
|
||||
return !player.inventory.getCurrentItem().isEmpty() && player.inventory.getCurrentItem().getItem() instanceof ItemFlamethrower;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -73,7 +66,6 @@ public class CommonPlayerTickHandler {
|
||||
|
||||
public void tickEnd(EntityPlayer player) {
|
||||
ItemStack feetStack = player.getItemStackFromSlot(EntityEquipmentSlot.FEET);
|
||||
|
||||
if (!feetStack.isEmpty() && feetStack.getItem() instanceof ItemFreeRunners && !player.isSneaking()) {
|
||||
player.stepHeight = 1.002F;
|
||||
} else if (player.stepHeight == 1.002F) {
|
||||
@@ -82,17 +74,14 @@ public class CommonPlayerTickHandler {
|
||||
|
||||
if (isFlamethrowerOn(player)) {
|
||||
player.world.spawnEntity(new EntityFlame(player));
|
||||
|
||||
if (!(player.isCreative() || player.isSpectator())) {
|
||||
((ItemFlamethrower) player.inventory.getCurrentItem().getItem())
|
||||
.useGas(player.inventory.getCurrentItem());
|
||||
((ItemFlamethrower) player.inventory.getCurrentItem().getItem()).useGas(player.inventory.getCurrentItem());
|
||||
}
|
||||
}
|
||||
|
||||
if (isJetpackOn(player)) {
|
||||
ItemStack stack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
|
||||
ItemJetpack jetpack = (ItemJetpack) stack.getItem();
|
||||
|
||||
if (jetpack.getMode(stack) == JetpackMode.NORMAL) {
|
||||
player.motionY = Math.min(player.motionY + 0.15D, 0.5D);
|
||||
} else if (jetpack.getMode(stack) == JetpackMode.HOVER) {
|
||||
@@ -105,39 +94,30 @@ public class CommonPlayerTickHandler {
|
||||
player.motionY = Math.min(player.motionY + 0.15D, 0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (Mekanism.keyMap.has(player, KeySync.ASCEND)) {
|
||||
player.motionY = Math.min(player.motionY + 0.15D, 0.2D);
|
||||
} else if (Mekanism.keyMap.has(player, KeySync.DESCEND)) {
|
||||
if (!isOnGround(player)) {
|
||||
player.motionY = Math.max(player.motionY - 0.15D, -0.2D);
|
||||
}
|
||||
} else if (Mekanism.keyMap.has(player, KeySync.ASCEND)) {
|
||||
player.motionY = Math.min(player.motionY + 0.15D, 0.2D);
|
||||
} else if (Mekanism.keyMap.has(player, KeySync.DESCEND)) {
|
||||
if (!isOnGround(player)) {
|
||||
player.motionY = Math.max(player.motionY - 0.15D, -0.2D);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
player.fallDistance = 0.0F;
|
||||
|
||||
if (player instanceof EntityPlayerMP) {
|
||||
((EntityPlayerMP) player).connection.floatingTickCount = 0;
|
||||
}
|
||||
|
||||
jetpack.useGas(stack);
|
||||
}
|
||||
|
||||
if (isGasMaskOn(player)) {
|
||||
ItemStack stack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
|
||||
ItemScubaTank tank = (ItemScubaTank) stack.getItem();
|
||||
|
||||
final int max = 300;
|
||||
|
||||
tank.useGas(stack);
|
||||
GasStack received = tank.useGas(stack, max - player.getAir());
|
||||
|
||||
if (received != null) {
|
||||
player.setAir(player.getAir() + received.amount);
|
||||
}
|
||||
|
||||
if (player.getAir() == max) {
|
||||
for (Object obj : player.getActivePotionEffects()) {
|
||||
if (obj instanceof PotionEffect) {
|
||||
@@ -152,29 +132,24 @@ public class CommonPlayerTickHandler {
|
||||
|
||||
public boolean isJetpackOn(EntityPlayer player) {
|
||||
ItemStack stack = player.inventory.armorInventory.get(2);
|
||||
|
||||
if (!stack.isEmpty() && !(player.isCreative() || player.isSpectator())) {
|
||||
if (stack.getItem() instanceof ItemJetpack) {
|
||||
ItemJetpack jetpack = (ItemJetpack) stack.getItem();
|
||||
|
||||
if (jetpack.getGas(stack) != null) {
|
||||
if ((Mekanism.keyMap.has(player, KeySync.ASCEND) && jetpack.getMode(stack) == JetpackMode.NORMAL)) {
|
||||
if (Mekanism.keyMap.has(player, KeySync.ASCEND) && jetpack.getMode(stack) == JetpackMode.NORMAL) {
|
||||
return true;
|
||||
} else if (jetpack.getMode(stack) == JetpackMode.HOVER) {
|
||||
if ((!Mekanism.keyMap.has(player, KeySync.ASCEND) && !Mekanism.keyMap
|
||||
.has(player, KeySync.DESCEND)) || (Mekanism.keyMap.has(player, KeySync.ASCEND)
|
||||
&& Mekanism.keyMap.has(player, KeySync.DESCEND))) {
|
||||
if ((!Mekanism.keyMap.has(player, KeySync.ASCEND) && !Mekanism.keyMap.has(player, KeySync.DESCEND)) ||
|
||||
(Mekanism.keyMap.has(player, KeySync.ASCEND) && Mekanism.keyMap.has(player, KeySync.DESCEND))) {
|
||||
return !isOnGround(player);
|
||||
} else if (Mekanism.keyMap.has(player, KeySync.DESCEND)) {
|
||||
return !isOnGround(player);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user