From 83bb0fd16fe45edd26254b23b420406a214333e3 Mon Sep 17 00:00:00 2001 From: Boblet Date: Wed, 13 Oct 2021 16:45:41 +0200 Subject: [PATCH] crane keybinds, fixed debris not saving, a surprise --- src/main/java/com/hbm/blocks/ModBlocks.java | 3 + .../java/com/hbm/blocks/gas/BlockVacuum.java | 105 ++++++++++++++++++ .../hbm/entity/projectile/EntityRubble.java | 15 +++ .../java/com/hbm/handler/HbmKeybinds.java | 19 +++- .../recipes/CrystallizerRecipes.java | 1 - .../java/com/hbm/lib/ModDamageSource.java | 1 + src/main/java/com/hbm/main/ClientProxy.java | 17 ++- .../com/hbm/main/ModEventHandlerClient.java | 20 +++- src/main/resources/assets/hbm/lang/de_DE.lang | 5 + src/main/resources/assets/hbm/lang/en_US.lang | 5 + .../assets/hbm/textures/armor/vacuum.png | Bin 0 -> 134 bytes 11 files changed, 181 insertions(+), 10 deletions(-) create mode 100644 src/main/java/com/hbm/blocks/gas/BlockVacuum.java create mode 100644 src/main/resources/assets/hbm/textures/armor/vacuum.png diff --git a/src/main/java/com/hbm/blocks/ModBlocks.java b/src/main/java/com/hbm/blocks/ModBlocks.java index 34ec63cc7..401d5f7bf 100644 --- a/src/main/java/com/hbm/blocks/ModBlocks.java +++ b/src/main/java/com/hbm/blocks/ModBlocks.java @@ -1077,6 +1077,7 @@ public class ModBlocks { public static Block gas_coal; public static Block gas_flammable; public static Block gas_explosive; + public static Block vacuum; public static Block absorber; public static Block absorber_red; @@ -2062,6 +2063,7 @@ public class ModBlocks { gas_coal = new BlockGasCoal().setBlockName("gas_coal").setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":gas_coal"); gas_flammable = new BlockGasFlammable().setBlockName("gas_flammable").setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":gas_flammable"); gas_explosive = new BlockGasExplosive().setBlockName("gas_explosive").setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":gas_explosive"); + vacuum = new BlockVacuum().setBlockName("vacuum").setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":vacuum"); absorber = new BlockAbsorber(Material.iron, 2.5F).setBlockName("absorber").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":absorber"); absorber_red = new BlockAbsorber(Material.iron, 10F).setBlockName("absorber_red").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":absorber_red"); @@ -3103,6 +3105,7 @@ public class ModBlocks { GameRegistry.registerBlock(gas_coal, gas_coal.getUnlocalizedName()); GameRegistry.registerBlock(gas_flammable, gas_flammable.getUnlocalizedName()); GameRegistry.registerBlock(gas_explosive, gas_explosive.getUnlocalizedName()); + GameRegistry.registerBlock(vacuum, vacuum.getUnlocalizedName()); //??? GameRegistry.registerBlock(crystal_virus, crystal_virus.getUnlocalizedName()); diff --git a/src/main/java/com/hbm/blocks/gas/BlockVacuum.java b/src/main/java/com/hbm/blocks/gas/BlockVacuum.java new file mode 100644 index 000000000..006f220a0 --- /dev/null +++ b/src/main/java/com/hbm/blocks/gas/BlockVacuum.java @@ -0,0 +1,105 @@ +package com.hbm.blocks.gas; + +import java.util.Random; + +import com.hbm.blocks.ModBlocks; +import com.hbm.lib.ModDamageSource; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.Item; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class BlockVacuum extends Block { + + public BlockVacuum() { + super(ModBlocks.materialGas); + this.setHardness(0.0F); + this.setResistance(0.0F); + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public int getRenderType() { + return -1; + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) { + return null; + } + + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { + return null; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) { + return false; + } + + @Override + public boolean canCollideCheck(int p_149678_1_, boolean p_149678_2_) { + return false; + } + + @Override + public boolean isReplaceable(IBlockAccess world, int x, int y, int z) { + return true; + } + + @Override + public void onBlockAdded(World world, int x, int y, int z) { + if(!world.isRemote) world.scheduleBlockUpdate(x, y, z, this, 1); + } + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + if(!world.isRemote) world.scheduleBlockUpdate(x, y, z, this, 1); + } + + @Override + public void updateTick(World world, int x, int y, int z, Random rand) { + + for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + + Block b = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ); + + if(b == this) + continue; + + if(b.getBlockBoundsMinX() > 0 || b.getBlockBoundsMinY() > 0 || b.getBlockBoundsMinZ() > 0 || + b.getBlockBoundsMaxX() < 1 || b.getBlockBoundsMaxY() < 1 || b.getBlockBoundsMaxZ() < 1) { + world.setBlockToAir(x, y, z); + return; + } + } + } + + @Override + public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { + + if(!(entity instanceof EntityLivingBase)) + return; + + entity.attackEntityFrom(ModDamageSource.vacuum, 1F); + } +} diff --git a/src/main/java/com/hbm/entity/projectile/EntityRubble.java b/src/main/java/com/hbm/entity/projectile/EntityRubble.java index d200dd4aa..82aedea6b 100644 --- a/src/main/java/com/hbm/entity/projectile/EntityRubble.java +++ b/src/main/java/com/hbm/entity/projectile/EntityRubble.java @@ -8,6 +8,7 @@ import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.projectile.EntityThrowable; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; @@ -60,4 +61,18 @@ public class EntityRubble extends EntityThrowable { this.dataWatcher.updateObject(16, Block.getIdFromBlock(b)); this.dataWatcher.updateObject(17, i); } + + @Override + public void readEntityFromNBT(NBTTagCompound nbt) { + super.readEntityFromNBT(nbt); + this.dataWatcher.updateObject(16, nbt.getInteger("block")); + this.dataWatcher.updateObject(17, nbt.getInteger("meta")); + } + + @Override + public void writeEntityToNBT(NBTTagCompound nbt) { + super.writeEntityToNBT(nbt); + nbt.setInteger("block", this.dataWatcher.getWatchableObjectInt(16)); + nbt.setInteger("meta", this.dataWatcher.getWatchableObjectInt(17)); + } } diff --git a/src/main/java/com/hbm/handler/HbmKeybinds.java b/src/main/java/com/hbm/handler/HbmKeybinds.java index 3dde39e3b..ad5b4d837 100644 --- a/src/main/java/com/hbm/handler/HbmKeybinds.java +++ b/src/main/java/com/hbm/handler/HbmKeybinds.java @@ -19,11 +19,23 @@ public class HbmKeybinds { public static KeyBinding jetpackKey = new KeyBinding(category + ".toggleBack", Keyboard.KEY_C, category); public static KeyBinding hudKey = new KeyBinding(category + ".toggleHUD", Keyboard.KEY_V, category); public static KeyBinding reloadKey = new KeyBinding(category + ".reload", Keyboard.KEY_R, category); + + public static KeyBinding craneUpKey = new KeyBinding(category + ".craneMoveUp", Keyboard.KEY_UP, category); + public static KeyBinding craneDownKey = new KeyBinding(category + ".craneMoveDown", Keyboard.KEY_DOWN, category); + public static KeyBinding craneLeftKey = new KeyBinding(category + ".craneMoveLeft", Keyboard.KEY_LEFT, category); + public static KeyBinding craneRightKey = new KeyBinding(category + ".craneMoveRight", Keyboard.KEY_RIGHT, category); + public static KeyBinding craneLoadKey = new KeyBinding(category + ".craneLoad", Keyboard.KEY_RETURN, category); public static void register() { ClientRegistry.registerKeyBinding(jetpackKey); ClientRegistry.registerKeyBinding(hudKey); ClientRegistry.registerKeyBinding(reloadKey); + + ClientRegistry.registerKeyBinding(craneUpKey); + ClientRegistry.registerKeyBinding(craneDownKey); + ClientRegistry.registerKeyBinding(craneLeftKey); + ClientRegistry.registerKeyBinding(craneRightKey); + ClientRegistry.registerKeyBinding(craneLoadKey); } @SubscribeEvent @@ -46,6 +58,11 @@ public class HbmKeybinds { JETPACK, TOGGLE_JETPACK, TOGGLE_HEAD, - RELOAD + RELOAD, + CRANE_UP, + CRANE_DOWN, + CRANE_LEFT, + CRANE_RIGHT, + CRANE_LOAD } } diff --git a/src/main/java/com/hbm/inventory/recipes/CrystallizerRecipes.java b/src/main/java/com/hbm/inventory/recipes/CrystallizerRecipes.java index e6d4369aa..84d1833a0 100644 --- a/src/main/java/com/hbm/inventory/recipes/CrystallizerRecipes.java +++ b/src/main/java/com/hbm/inventory/recipes/CrystallizerRecipes.java @@ -37,7 +37,6 @@ public class CrystallizerRecipes { recipes.put("orePlutonium", new ItemStack(ModItems.crystal_plutonium)); recipes.put("oreTitanium", new ItemStack(ModItems.crystal_titanium)); recipes.put("oreSulfur", new ItemStack(ModItems.crystal_sulfur)); - recipes.put("oreNiter", new ItemStack(ModItems.crystal_niter)); recipes.put("oreSaltpeter", new ItemStack(ModItems.crystal_niter)); recipes.put("oreCopper", new ItemStack(ModItems.crystal_copper)); recipes.put("oreTungsten", new ItemStack(ModItems.crystal_tungsten)); diff --git a/src/main/java/com/hbm/lib/ModDamageSource.java b/src/main/java/com/hbm/lib/ModDamageSource.java index 3b08eb0f0..49d9dfbd5 100644 --- a/src/main/java/com/hbm/lib/ModDamageSource.java +++ b/src/main/java/com/hbm/lib/ModDamageSource.java @@ -50,6 +50,7 @@ public class ModDamageSource extends DamageSource { public static DamageSource asbestos = (new DamageSource("asbestos")).setDamageIsAbsolute().setDamageBypassesArmor(); public static DamageSource blacklung = (new DamageSource("blacklung")).setDamageIsAbsolute().setDamageBypassesArmor(); public static DamageSource mku = (new DamageSource("mku")).setDamageIsAbsolute().setDamageBypassesArmor(); + public static DamageSource vacuum = (new DamageSource("vacuum")).setDamageIsAbsolute().setDamageBypassesArmor(); public static final String s_bullet = "revolverBullet"; public static final String s_emplacer = "chopperBullet"; diff --git a/src/main/java/com/hbm/main/ClientProxy.java b/src/main/java/com/hbm/main/ClientProxy.java index d8805d5f3..06724dbde 100644 --- a/src/main/java/com/hbm/main/ClientProxy.java +++ b/src/main/java/com/hbm/main/ClientProxy.java @@ -1515,12 +1515,17 @@ public class ClientProxy extends ServerProxy { @Override public boolean getIsKeyPressed(EnumKeybind key) { - if(key == EnumKeybind.JETPACK) - return Minecraft.getMinecraft().gameSettings.keyBindJump.getIsKeyPressed(); - if(key == EnumKeybind.TOGGLE_JETPACK) - return HbmKeybinds.jetpackKey.getIsKeyPressed(); - if(key == EnumKeybind.TOGGLE_HEAD) - return HbmKeybinds.hudKey.getIsKeyPressed(); + switch(key){ + case JETPACK: return Minecraft.getMinecraft().gameSettings.keyBindJump.getIsKeyPressed(); + case TOGGLE_JETPACK: return HbmKeybinds.jetpackKey.getIsKeyPressed(); + case TOGGLE_HEAD: return HbmKeybinds.hudKey.getIsKeyPressed(); + case RELOAD: return HbmKeybinds.reloadKey.getIsKeyPressed(); + case CRANE_UP: return HbmKeybinds.craneUpKey.getIsKeyPressed(); + case CRANE_DOWN: return HbmKeybinds.craneDownKey.getIsKeyPressed(); + case CRANE_LEFT: return HbmKeybinds.craneLeftKey.getIsKeyPressed(); + case CRANE_RIGHT: return HbmKeybinds.craneRightKey.getIsKeyPressed(); + case CRANE_LOAD: return HbmKeybinds.craneLoadKey.getIsKeyPressed(); + } return false; } diff --git a/src/main/java/com/hbm/main/ModEventHandlerClient.java b/src/main/java/com/hbm/main/ModEventHandlerClient.java index 4b7e5f904..21bf87278 100644 --- a/src/main/java/com/hbm/main/ModEventHandlerClient.java +++ b/src/main/java/com/hbm/main/ModEventHandlerClient.java @@ -6,6 +6,7 @@ import java.util.Random; import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; +import com.hbm.blocks.ModBlocks; import com.hbm.blocks.generic.BlockAshes; import com.hbm.entity.mob.EntityHunterChopper; import com.hbm.entity.projectile.EntityChopperMine; @@ -67,6 +68,7 @@ import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent; import cpw.mods.fml.common.gameevent.TickEvent.Phase; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.gui.ScaledResolution; @@ -83,6 +85,7 @@ import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import net.minecraft.util.Vec3; import net.minecraft.world.World; @@ -401,9 +404,22 @@ public class ModEventHandlerClient { @Spaghetti("please get this shit out of my face") @SubscribeEvent public void onPlaySound(PlaySoundEvent17 e) { + + EntityPlayer player = MainRegistry.proxy.me(); + Minecraft mc = Minecraft.getMinecraft(); + int i = MathHelper.floor_double(mc.thePlayer.posX); + int j = MathHelper.floor_double(mc.thePlayer.posY); + int k = MathHelper.floor_double(mc.thePlayer.posZ); + Block block = mc.theWorld.getBlock(i, j, k); + + if(block == ModBlocks.vacuum) { + e.result = null; + return; + } + ResourceLocation r = e.sound.getPositionedSoundLocation(); - WorldClient wc = Minecraft.getMinecraft().theWorld; + WorldClient wc = mc.theWorld; //Alright, alright, I give the fuck up, you've wasted my time enough with this bullshit. You win. //A winner is you. @@ -458,7 +474,7 @@ public class ModEventHandlerClient { if(!sounds.init || sounds.isDonePlaying()) { sounds.init = true; sounds.setDone(false); - Minecraft.getMinecraft().getSoundHandler().playSound(sounds); + mc.getSoundHandler().playSound(sounds); } } } diff --git a/src/main/resources/assets/hbm/lang/de_DE.lang b/src/main/resources/assets/hbm/lang/de_DE.lang index 697965130..29893be17 100644 --- a/src/main/resources/assets/hbm/lang/de_DE.lang +++ b/src/main/resources/assets/hbm/lang/de_DE.lang @@ -410,6 +410,11 @@ hazard.particleFine=Feinstaub hazard.sand=Augenreizstoffe hbm.key=NTM Hotkeys +hbm.key.craneLoad=Kran laden/entladen +hbm.key.craneMoveDown=Kran rückwärts +hbm.key.craneMoveLeft=Kran nach links +hbm.key.craneMoveRight=Kran nach rechts +hbm.key.craneMoveUp=Kran vorwärts hbm.key.toggleBack=Rucksack umschalten hbm.key.toggleHUD=HUD umschalten hbm.key.reload=Nachladen diff --git a/src/main/resources/assets/hbm/lang/en_US.lang b/src/main/resources/assets/hbm/lang/en_US.lang index b4340646a..b0d2d9681 100644 --- a/src/main/resources/assets/hbm/lang/en_US.lang +++ b/src/main/resources/assets/hbm/lang/en_US.lang @@ -478,6 +478,11 @@ hazard.particleFine=Particulates hazard.sand=Eye Irritants hbm.key=NTM Hotkeys +hbm.key.craneLoad=Load/Unload Crane +hbm.key.craneMoveDown=Move Crane Backward +hbm.key.craneMoveLeft=Move Crane Left +hbm.key.craneMoveRight=Move Crane Right +hbm.key.craneMoveUp=Move Crane Forward hbm.key.toggleBack=Toggle Backpack hbm.key.toggleHUD=Toggle HUD hbm.key.reload=Reload diff --git a/src/main/resources/assets/hbm/textures/armor/vacuum.png b/src/main/resources/assets/hbm/textures/armor/vacuum.png new file mode 100644 index 0000000000000000000000000000000000000000..3636b9ca4afdb4542ca35b42254cc85709427517 GIT binary patch literal 134 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`EX7WqAsj$Z!;#VfIEGmC zCWnNC{5kKyn2?x|knrQ*U+Yvh10dK_@v$l8tdNipk55W8FY98q9w`GKo`!TaPEO8E aJPZs4PuRES