From 2ef47c8604bf0347e87d0758aa7360a0ac27c39b Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 20 Jun 2023 20:28:00 +0200 Subject: [PATCH] better pathfinding, BDCL, nuclear glyphid improvements --- .../com/hbm/entity/mob/EntityGlyphid.java | 11 ++-- .../hbm/entity/mob/EntityGlyphidNuclear.java | 34 ++++++---- .../entity/pathfinder/PathFinderUtils.java | 62 ++++++++++++++++++ .../com/hbm/inventory/OreDictManager.java | 2 + .../inventory/recipes/AssemblerRecipes.java | 2 +- src/main/java/com/hbm/items/ModItems.java | 3 + .../java/com/hbm/items/food/ItemBDCL.java | 34 ++++++++++ .../hbm/items/tool/ItemPollutionDetector.java | 8 +-- src/main/resources/assets/hbm/lang/de_DE.lang | 1 + src/main/resources/assets/hbm/lang/en_US.lang | 1 + .../assets/hbm/textures/items/bdcl.png | Bin 0 -> 253 bytes 11 files changed, 133 insertions(+), 25 deletions(-) create mode 100644 src/main/java/com/hbm/entity/pathfinder/PathFinderUtils.java create mode 100644 src/main/java/com/hbm/items/food/ItemBDCL.java create mode 100644 src/main/resources/assets/hbm/textures/items/bdcl.png diff --git a/src/main/java/com/hbm/entity/mob/EntityGlyphid.java b/src/main/java/com/hbm/entity/mob/EntityGlyphid.java index ab3e9ac51..775c7ea55 100644 --- a/src/main/java/com/hbm/entity/mob/EntityGlyphid.java +++ b/src/main/java/com/hbm/entity/mob/EntityGlyphid.java @@ -4,6 +4,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import com.hbm.entity.pathfinder.PathFinderUtils; import com.hbm.main.ResourceManager; import net.minecraft.entity.Entity; @@ -64,8 +65,9 @@ public class EntityGlyphid extends EntityMob { protected void updateEntityActionState() { super.updateEntityActionState(); - if(this.entityToAttack != null) { - this.setPathToEntity(this.worldObj.getPathEntityToEntity(this, this.entityToAttack, 128F, true, false, false, true)); + // hell yeah!! + if(this.entityToAttack != null && !this.hasPath()) { + this.setPathToEntity(PathFinderUtils.getPathEntityToEntityPartial(worldObj, this, this.entityToAttack, 16F, true, false, false, true)); } } @@ -73,11 +75,6 @@ public class EntityGlyphid extends EntityMob { protected boolean canDespawn() { return entityToAttack == null; } - - @Override - public int getMaxSafePointTries() { - return 10; - } @Override public boolean attackEntityFrom(DamageSource source, float amount) { diff --git a/src/main/java/com/hbm/entity/mob/EntityGlyphidNuclear.java b/src/main/java/com/hbm/entity/mob/EntityGlyphidNuclear.java index 8c6590203..62a3ae9a6 100644 --- a/src/main/java/com/hbm/entity/mob/EntityGlyphidNuclear.java +++ b/src/main/java/com/hbm/entity/mob/EntityGlyphidNuclear.java @@ -79,22 +79,30 @@ public class EntityGlyphidNuclear extends EntityGlyphid { if(this.deathTicks == 100) { - ExplosionVNT vnt = new ExplosionVNT(worldObj, posX, posY, posZ, 25, this); - vnt.setBlockAllocator(new BlockAllocatorStandard(24)); - vnt.setBlockProcessor(new BlockProcessorStandard().withBlockEffect(new BlockMutatorDebris(ModBlocks.volcanic_lava_block, 0)).setNoDrop()); - vnt.setEntityProcessor(new EntityProcessorStandard().withRangeMod(1.5F)); - vnt.setPlayerProcessor(new PlayerProcessorStandard()); - vnt.explode(); - - NBTTagCompound data = new NBTTagCompound(); - data.setString("type", "muke"); - // if the FX type is "muke", apply random BF effect - if(MainRegistry.polaroidID == 11 || rand.nextInt(100) == 0) { - data.setBoolean("balefire", true); + if(!worldObj.isRemote) { + ExplosionVNT vnt = new ExplosionVNT(worldObj, posX, posY, posZ, 25, this); + vnt.setBlockAllocator(new BlockAllocatorStandard(24)); + vnt.setBlockProcessor(new BlockProcessorStandard().withBlockEffect(new BlockMutatorDebris(ModBlocks.volcanic_lava_block, 0)).setNoDrop()); + vnt.setEntityProcessor(new EntityProcessorStandard().withRangeMod(1.5F)); + vnt.setPlayerProcessor(new PlayerProcessorStandard()); + vnt.explode(); + + worldObj.playSoundEffect(posX, posY, posZ, "hbm:weapon.mukeExplosion", 15.0F, 1.0F); + + NBTTagCompound data = new NBTTagCompound(); + data.setString("type", "muke"); + // if the FX type is "muke", apply random BF effect + if(MainRegistry.polaroidID == 11 || rand.nextInt(100) == 0) { + data.setBoolean("balefire", true); + } + PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, posX, posY + 0.5, posZ), new TargetPoint(dimension, posX, posY, posZ, 250)); } - PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, posX, posY + 0.5, posZ), new TargetPoint(dimension, posX, posY, posZ, 250)); this.setDead(); + } else { + if(!worldObj.isRemote && this.deathTicks % 10 == 0) { + worldObj.playSoundEffect(posX, posY, posZ, "hbm:weapon.fstbmbPing", 5.0F, 1.0F); + } } } } diff --git a/src/main/java/com/hbm/entity/pathfinder/PathFinderUtils.java b/src/main/java/com/hbm/entity/pathfinder/PathFinderUtils.java new file mode 100644 index 000000000..9d5b2f36c --- /dev/null +++ b/src/main/java/com/hbm/entity/pathfinder/PathFinderUtils.java @@ -0,0 +1,62 @@ +package com.hbm.entity.pathfinder; + +import net.minecraft.entity.Entity; +import net.minecraft.pathfinding.PathEntity; +import net.minecraft.pathfinding.PathFinder; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; +import net.minecraft.world.ChunkCache; +import net.minecraft.world.World; + +public class PathFinderUtils { + + public static PathEntity getPathEntityToEntityPartial(World world, Entity fromEntity, Entity toEntity, float maxDist, boolean allowDoors, boolean allowBlocked, boolean allowWater, boolean canDrown) { + world.theProfiler.startSection("pathfind"); + int startX = MathHelper.floor_double(fromEntity.posX); + int startY = MathHelper.floor_double(fromEntity.posY + 1.0D); + int startZ = MathHelper.floor_double(fromEntity.posZ); + int maxDistEff = (int) (maxDist + 16.0F); + int minX = startX - maxDistEff; + int minY = startY - maxDistEff; + int minZ = startZ - maxDistEff; + int maxX = startX + maxDistEff; + int maxY = startY + maxDistEff; + int maxZ = startZ + maxDistEff; + ChunkCache chunkcache = new ChunkCache(world, minX, minY, minZ, maxX, maxY, maxZ, 0); + + Vec3 vec = Vec3.createVectorHelper(toEntity.posX - fromEntity.posX, toEntity.posY - fromEntity.posY, toEntity.posZ - fromEntity.posZ); + vec = vec.normalize(); + vec.xCoord *= maxDist; + vec.yCoord *= maxDist; + vec.zCoord *= maxDist; + + int x = (int) Math.floor(fromEntity.posX + vec.xCoord); + int y = (int) Math.floor(fromEntity.posY + vec.yCoord); + int z = (int) Math.floor(fromEntity.posZ + vec.zCoord); + + //this part will adjust the end of the path so it's actually on the ground, it being unreachable causes mobs to slow down + boolean solid = false; + + for(int i = y; i > y - 10; i--) { + if(!world.getBlock(x, i, z).getMaterial().blocksMovement() && world.getBlock(x, i - 1, z).isNormalCube()) { + solid = true; + y = i; + break; + } + + } + + if(!solid) for(int i = y + 10; i > y; i--) { + if(!world.getBlock(x, i, z).getMaterial().blocksMovement() && world.getBlock(x, i - 1, z).isNormalCube()) { + solid = true; + y = i; + break; + } + } + + //PathEntity pathentity = (new PathFinder(chunkcache, allowDoors, allowBlocked, allowWater, canDrown)).createEntityPathTo(fromEntity, toEntity, maxDist); + PathEntity pathentity = (new PathFinder(chunkcache, allowDoors, allowBlocked, allowWater, canDrown)).createEntityPathTo(fromEntity, x, y, z, maxDist); + world.theProfiler.endSection(); + return pathentity; + } +} diff --git a/src/main/java/com/hbm/inventory/OreDictManager.java b/src/main/java/com/hbm/inventory/OreDictManager.java index 69e41bd65..271f58aac 100644 --- a/src/main/java/com/hbm/inventory/OreDictManager.java +++ b/src/main/java/com/hbm/inventory/OreDictManager.java @@ -574,6 +574,8 @@ public class OreDictManager { OreDictionary.registerOre("blockGlassLime", glass_trinitite); OreDictionary.registerOre("blockGlassRed", glass_polonium); OreDictionary.registerOre("blockGlassBlack", glass_ash); + + OreDictionary.registerOre("container1000lubricant", bdcl); MaterialShapes.registerCompatShapes(); } diff --git a/src/main/java/com/hbm/inventory/recipes/AssemblerRecipes.java b/src/main/java/com/hbm/inventory/recipes/AssemblerRecipes.java index 38ae7cf5b..3711f5af2 100644 --- a/src/main/java/com/hbm/inventory/recipes/AssemblerRecipes.java +++ b/src/main/java/com/hbm/inventory/recipes/AssemblerRecipes.java @@ -281,7 +281,7 @@ public class AssemblerRecipes { makeRecipe(new ComparableStack(ModBlocks.machine_flare, 1), new AStack[] {new OreDictStack(STEEL.ingot(), 12), new OreDictStack(IRON.ingot(), 12), new OreDictStack(CU.plate528(), 4), new ComparableStack(ModItems.tank_steel, 1), new ComparableStack(ModBlocks.deco_pipe_quad, 8), new ComparableStack(ModItems.hull_small_steel, 4), new ComparableStack(ModItems.thermo_element, 3), },200); makeRecipe(new ComparableStack(ModBlocks.machine_coker, 1), new AStack[] {new OreDictStack(STEEL.plate(), 24), new OreDictStack(IRON.ingot(), 12), new OreDictStack(CU.plate528(), 8), new OreDictStack(RUBBER.ingot(), 4), new ComparableStack(ModItems.tank_steel, 2), new ComparableStack(ModBlocks.steel_grate, 4) },200); makeRecipe(new ComparableStack(ModBlocks.machine_refinery, 1), new AStack[] {new OreDictStack(STEEL.plate528(), 16), new OreDictStack(CU.plate(), 16), new ComparableStack(ModItems.hull_big_steel, 6), new ComparableStack(ModItems.pipes_steel, 2), new ComparableStack(ModItems.plate_polymer, 8), new ComparableStack(ModItems.circuit_red_copper, 1) },350); - makeRecipe(new ComparableStack(ModBlocks.machine_epress, 1), new AStack[] {new OreDictStack(STEEL.plate(), 8), new ComparableStack(ModItems.plate_polymer, 4), new ComparableStack(ModItems.bolt_tungsten, 4), new ComparableStack(ModItems.coil_copper, 2), new ComparableStack(ModItems.motor, 1), new ComparableStack(ModItems.circuit_copper, 1), new ComparableStack(ModItems.canister_full, 1, Fluids.LUBRICANT.getID()), },160); + makeRecipe(new ComparableStack(ModBlocks.machine_epress, 1), new AStack[] {new OreDictStack(STEEL.plate(), 8), new ComparableStack(ModItems.plate_polymer, 4), new ComparableStack(ModItems.bolt_tungsten, 4), new ComparableStack(ModItems.coil_copper, 2), new ComparableStack(ModItems.motor, 1), new ComparableStack(ModItems.circuit_copper, 1), new OreDictStack(Fluids.LUBRICANT.getDict(1000)), },160); makeRecipe(new ComparableStack(ModBlocks.machine_chemplant, 1), new AStack[] {new OreDictStack(STEEL.ingot(), 8), new OreDictStack(CU.plate528(), 6), new ComparableStack(ModItems.tank_steel, 4), new ComparableStack(ModItems.hull_big_steel, 1), new ComparableStack(ModItems.coil_tungsten, 3), new ComparableStack(ModItems.circuit_copper, 2), new ComparableStack(ModItems.circuit_red_copper, 1), new ComparableStack(ModItems.plate_polymer, 8), },200); makeRecipe(new ComparableStack(ModBlocks.machine_crystallizer, 1), new AStack[] {new ComparableStack(ModItems.hull_big_steel, 4), new ComparableStack(ModItems.pipes_steel, 1), new OreDictStack(DESH.ingot(), 4), new ComparableStack(ModItems.motor, 2), new ComparableStack(ModItems.blades_advanced_alloy, 2), new OreDictStack(STEEL.ingot(), 16), new OreDictStack(TI.plate(), 16), new ComparableStack(Blocks.glass, 4), new ComparableStack(ModItems.circuit_gold, 1), },400); makeRecipe(new ComparableStack(ModBlocks.machine_fluidtank, 1), new AStack[] {new OreDictStack(STEEL.ingot(), 2), new OreDictStack(STEEL.plate528(), 6), new ComparableStack(ModItems.hull_big_steel, 4), new OreDictStack(ANY_TAR.any(), 4), },150); diff --git a/src/main/java/com/hbm/items/ModItems.java b/src/main/java/com/hbm/items/ModItems.java index 35b9cb0d5..0b065d7a3 100644 --- a/src/main/java/com/hbm/items/ModItems.java +++ b/src/main/java/com/hbm/items/ModItems.java @@ -1007,6 +1007,7 @@ public class ModItems { public static Item cap_sunset; public static Item cap_star; public static Item ring_pull; + public static Item bdcl; //public static Item canned_beef; //public static Item canned_tuna; //public static Item canned_mystery; @@ -3341,6 +3342,7 @@ public class ModItems { cbt_device = new ItemSyringe().setUnlocalizedName("cbt_device").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":cbt_device"); cigarette = new ItemCigarette().setUnlocalizedName("cigarette").setFull3D().setMaxStackSize(16).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":cigarette"); crackpipe = new ItemCigarette().setUnlocalizedName("crackpipe").setFull3D().setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":crackpipe"); + bdcl = new ItemBDCL().setUnlocalizedName("bdcl").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":bdcl"); attachment_mask = new ItemModGasmask().setUnlocalizedName("attachment_mask").setTextureName(RefStrings.MODID + ":attachment_mask"); attachment_mask_mono = new ItemModGasmask().setUnlocalizedName("attachment_mask_mono").setTextureName(RefStrings.MODID + ":attachment_mask_mono"); @@ -7618,6 +7620,7 @@ public class ModItems { GameRegistry.registerItem(cbt_device, cbt_device.getUnlocalizedName()); GameRegistry.registerItem(cigarette, cigarette.getUnlocalizedName()); GameRegistry.registerItem(crackpipe, crackpipe.getUnlocalizedName()); + GameRegistry.registerItem(bdcl, bdcl.getUnlocalizedName()); //Armor mods GameRegistry.registerItem(attachment_mask, attachment_mask.getUnlocalizedName()); diff --git a/src/main/java/com/hbm/items/food/ItemBDCL.java b/src/main/java/com/hbm/items/food/ItemBDCL.java new file mode 100644 index 000000000..1ec41d032 --- /dev/null +++ b/src/main/java/com/hbm/items/food/ItemBDCL.java @@ -0,0 +1,34 @@ +package com.hbm.items.food; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumAction; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class ItemBDCL extends Item { + + @Override + public int getMaxItemUseDuration(ItemStack p_77626_1_) { + return 32; + } + + @Override + public EnumAction getItemUseAction(ItemStack p_77661_1_) { + return EnumAction.drink; + } + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + player.setItemInUse(stack, this.getMaxItemUseDuration(stack)); + return stack; + } + + @Override + public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player) { + + if(!player.capabilities.isCreativeMode) { + --stack.stackSize; + } + return stack; + } +} diff --git a/src/main/java/com/hbm/items/tool/ItemPollutionDetector.java b/src/main/java/com/hbm/items/tool/ItemPollutionDetector.java index dca184a67..9b1a14ec3 100644 --- a/src/main/java/com/hbm/items/tool/ItemPollutionDetector.java +++ b/src/main/java/com/hbm/items/tool/ItemPollutionDetector.java @@ -29,10 +29,10 @@ public class ItemPollutionDetector extends Item { float heavymetal = data.pollution[PollutionType.HEAVYMETAL.ordinal()]; float fallout = data.pollution[PollutionType.FALLOUT.ordinal()]; - soot = ((int) soot * 100) / 100F; - poison = ((int) poison * 100) / 100F; - heavymetal = ((int) heavymetal * 100) / 100F; - fallout = ((int) fallout * 100) / 100F; + soot = ((int) (soot * 100)) / 100F; + poison = ((int) (poison * 100)) / 100F; + heavymetal = ((int) (heavymetal * 100)) / 100F; + fallout = ((int) (fallout * 100)) / 100F; PacketDispatcher.wrapper.sendTo(new PlayerInformPacket(ChatBuilder.start("Soot: " + soot).color(EnumChatFormatting.YELLOW).flush(), 100, 2000), (EntityPlayerMP) entity); PacketDispatcher.wrapper.sendTo(new PlayerInformPacket(ChatBuilder.start("Poison: " + poison).color(EnumChatFormatting.YELLOW).flush(), 101, 2000), (EntityPlayerMP) entity); diff --git a/src/main/resources/assets/hbm/lang/de_DE.lang b/src/main/resources/assets/hbm/lang/de_DE.lang index 5e2693e41..c9a2b3a46 100644 --- a/src/main/resources/assets/hbm/lang/de_DE.lang +++ b/src/main/resources/assets/hbm/lang/de_DE.lang @@ -1160,6 +1160,7 @@ item.battery_steam_large.name=Großer dampfbetriebener Energiespeichertank item.battery_su.name=Einwegbatterie item.battery_su_l.name=Große Einwegbatterie item.battery_trixite.name=Billige Spark-Batterie-Nachmache +item.bdcl.name=BDCL item.beta.name=Beta-Features item.big_sword.name=Großes Schwert item.billet_am_mix.name=Reaktorfähiges Americiumbillet diff --git a/src/main/resources/assets/hbm/lang/en_US.lang b/src/main/resources/assets/hbm/lang/en_US.lang index 846ac5558..652cd70fa 100644 --- a/src/main/resources/assets/hbm/lang/en_US.lang +++ b/src/main/resources/assets/hbm/lang/en_US.lang @@ -1743,6 +1743,7 @@ item.battery_steam_large.name=Large Steam Powered Energy Storage Tank item.battery_su.name=SU-Battery item.battery_su_l.name=Large SU-Battery item.battery_trixite.name=Off-Brand Spark Battery +item.bdcl.name=BDCL item.beta.name=Beta Features item.big_sword.name=Great Sword item.billet_actinium.name=Actinium-227 Billet diff --git a/src/main/resources/assets/hbm/textures/items/bdcl.png b/src/main/resources/assets/hbm/textures/items/bdcl.png new file mode 100644 index 0000000000000000000000000000000000000000..999de5f9091dbd5109e2a41ecd45f28e02170f14 GIT binary patch literal 253 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`EX7WqAsj$Z!;#VfS{VV?8diRxwWI{p164^NRD;ZA~23AWy+3}r`T}M+X ziDAy?HR7|^m7YH*#izJov)d96p^Ur5ks&wUedGAY#30dDY@{L?Aa?a~)to&ZyM(^Y z>{u|R$&iiVLTT)!{ep|vTODnFwB(Jx%>AY5O*0u6