From 73367570b87c2b08180b040494ef6817d1d89528 Mon Sep 17 00:00:00 2001 From: Bob Date: Sun, 7 May 2023 20:30:54 +0200 Subject: [PATCH] tram passenger seats --- gradle.properties | 2 +- .../java/com/hbm/entity/EntityMappings.java | 4 +- .../com/hbm/entity/mob/EntityCreeperGold.java | 15 ++- .../hbm/entity/mob/EntityCreeperVolatile.java | 12 +- .../hbm/entity/train/EntityRailCarBase.java | 11 -- .../entity/train/EntityRailCarRidable.java | 106 +++++++++++++++++- .../com/hbm/entity/train/TrainCargoTram.java | 15 ++- src/main/java/com/hbm/lib/RefStrings.java | 2 +- src/main/java/com/hbm/main/MainRegistry.java | 2 +- .../com/hbm/main/ModEventHandlerClient.java | 4 +- .../machine/TileEntityMachinePress.java | 7 +- .../tileentity/machine/TileEntityTesla.java | 10 +- src/main/resources/assets/hbm/lang/de_DE.lang | 2 + src/main/resources/assets/hbm/lang/en_US.lang | 2 + ..._CHOLERSTEROL.png => tank_CHOLESTEROL.png} | Bin 15 files changed, 161 insertions(+), 33 deletions(-) rename src/main/resources/assets/hbm/textures/models/tank/{tank_CHOLERSTEROL.png => tank_CHOLESTEROL.png} (100%) diff --git a/gradle.properties b/gradle.properties index 311c2314be..697f43ef43 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ mod_version=1.0.27 # Empty build number makes a release type -mod_build_number=4585 +mod_build_number=4592 credits=HbMinecraft, rodolphito (explosion algorithms), grangerave (explosion algorithms),\ \ Hoboy (textures, models), Doctor17 (russian localization), Drillgon200 (effects, models, porting),\ diff --git a/src/main/java/com/hbm/entity/EntityMappings.java b/src/main/java/com/hbm/entity/EntityMappings.java index 23a8e70fde..d5354b59a6 100644 --- a/src/main/java/com/hbm/entity/EntityMappings.java +++ b/src/main/java/com/hbm/entity/EntityMappings.java @@ -14,6 +14,7 @@ import com.hbm.entity.mob.siege.*; import com.hbm.entity.particle.*; import com.hbm.entity.projectile.*; +import com.hbm.entity.train.EntityRailCarRidable.SeatDummyEntity; import com.hbm.entity.train.TrainCargoTram; import com.hbm.main.MainRegistry; import com.hbm.util.Tuple.Quartet; @@ -209,7 +210,8 @@ public static void writeMappings() { addEntity(EntitySawblade.class, "entity_stray_saw", 1000); addEntity(EntityChemical.class, "entity_chemthrower_splash", 1000); addEntity(EntityMist.class, "entity_mist", 1000); - + + addEntity(SeatDummyEntity.class, "entity_ntm_seat_dummy", 250, false); addEntity(TrainCargoTram.class, "entity_ntm_cargo_tram", 250, false); addMob(EntityCreeperNuclear.class, "entity_mob_nuclear_creeper", 0x204131, 0x75CE00); diff --git a/src/main/java/com/hbm/entity/mob/EntityCreeperGold.java b/src/main/java/com/hbm/entity/mob/EntityCreeperGold.java index d9ab7d3b67..70ad6fbe99 100644 --- a/src/main/java/com/hbm/entity/mob/EntityCreeperGold.java +++ b/src/main/java/com/hbm/entity/mob/EntityCreeperGold.java @@ -2,9 +2,11 @@ import com.hbm.explosion.vanillant.ExplosionVNT; import com.hbm.explosion.vanillant.standard.*; +import com.hbm.items.ModItems; import net.minecraft.entity.monster.EntityCreeper; import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class EntityCreeperGold extends EntityCreeper { @@ -19,8 +21,8 @@ public void func_146077_cc() { if(!this.worldObj.isRemote) { this.setDead(); - ExplosionVNT vnt = new ExplosionVNT(worldObj, posX, posY, posZ, 7); - vnt.setBlockAllocator(new BlockAllocatorBulkie(60)); + ExplosionVNT vnt = new ExplosionVNT(worldObj, posX, posY, posZ, this.getPowered() ? 14 : 7, this); + vnt.setBlockAllocator(new BlockAllocatorBulkie(60, this.getPowered() ? 32 : 16)); vnt.setBlockProcessor(new BlockProcessorStandard().withBlockEffect(new BlockMutatorBulkie(Blocks.gold_ore))); vnt.setEntityProcessor(new EntityProcessorStandard().withRangeMod(0.5F)); vnt.setPlayerProcessor(new PlayerProcessorStandard()); @@ -33,4 +35,13 @@ public void func_146077_cc() { public boolean getCanSpawnHere() { return super.getCanSpawnHere() && this.posY <= 40; } + + @Override + protected void dropFewItems(boolean byPlayer, int looting) { + + int amount = byPlayer ? 5 + rand.nextInt(6 + looting * 2) : 3; + for(int i = 0; i < amount; ++i) { + this.entityDropItem(new ItemStack(ModItems.crystal_gold), 0F); + } + } } diff --git a/src/main/java/com/hbm/entity/mob/EntityCreeperVolatile.java b/src/main/java/com/hbm/entity/mob/EntityCreeperVolatile.java index d957c7aca5..17160b15e8 100644 --- a/src/main/java/com/hbm/entity/mob/EntityCreeperVolatile.java +++ b/src/main/java/com/hbm/entity/mob/EntityCreeperVolatile.java @@ -3,8 +3,10 @@ import com.hbm.blocks.ModBlocks; import com.hbm.explosion.vanillant.ExplosionVNT; import com.hbm.explosion.vanillant.standard.*; +import com.hbm.items.ModItems; import net.minecraft.entity.monster.EntityCreeper; +import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class EntityCreeperVolatile extends EntityCreeper { @@ -19,8 +21,8 @@ public void func_146077_cc() { if(!this.worldObj.isRemote) { this.setDead(); - ExplosionVNT vnt = new ExplosionVNT(worldObj, posX, posY, posZ, 7); - vnt.setBlockAllocator(new BlockAllocatorBulkie(60)); + ExplosionVNT vnt = new ExplosionVNT(worldObj, posX, posY, posZ, this.getPowered() ? 14 : 7, this); + vnt.setBlockAllocator(new BlockAllocatorBulkie(60, this.getPowered() ? 32 : 16)); vnt.setBlockProcessor(new BlockProcessorStandard().withBlockEffect(new BlockMutatorBulkie(ModBlocks.block_slag, 1))); vnt.setEntityProcessor(new EntityProcessorStandard().withRangeMod(0.5F)); vnt.setPlayerProcessor(new PlayerProcessorStandard()); @@ -33,4 +35,10 @@ public void func_146077_cc() { public boolean getCanSpawnHere() { return super.getCanSpawnHere() && this.posY <= 40; } + + @Override + protected void dropFewItems(boolean byPlayer, int looting) { + this.entityDropItem(new ItemStack(ModItems.sulfur, 2 + rand.nextInt(3)), 0F); + this.entityDropItem(new ItemStack(ModItems.stick_tnt, 1 + rand.nextInt(2)), 0F); + } } diff --git a/src/main/java/com/hbm/entity/train/EntityRailCarBase.java b/src/main/java/com/hbm/entity/train/EntityRailCarBase.java index 750dc5765d..39a31c6252 100644 --- a/src/main/java/com/hbm/entity/train/EntityRailCarBase.java +++ b/src/main/java/com/hbm/entity/train/EntityRailCarBase.java @@ -3,21 +3,13 @@ import com.hbm.blocks.rail.IRailNTM; import com.hbm.blocks.rail.IRailNTM.RailContext; import com.hbm.blocks.rail.IRailNTM.TrackGauge; -import com.hbm.main.MainRegistry; -import com.hbm.packet.PacketDispatcher; -import com.hbm.packet.PlayerInformPacket; -import com.hbm.util.ChatBuilder; -import com.hbm.util.ParticleUtil; import com.hbm.util.fauxpointtwelve.BlockPos; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.MathHelper; import net.minecraft.util.Vec3; import net.minecraft.world.World; @@ -96,9 +88,6 @@ public void onUpdate() { this.velocityChanged = true; } } - - PacketDispatcher.wrapper.sendTo(new PlayerInformPacket(new ChatComponentText("Yaw: " + this.rotationYaw), 664, 3000), (EntityPlayerMP) worldObj.playerEntities.get(0)); - PacketDispatcher.wrapper.sendTo(new PlayerInformPacket(new ChatComponentText("MYaw: " + this.movementYaw), 665, 3000), (EntityPlayerMP) worldObj.playerEntities.get(0)); } } diff --git a/src/main/java/com/hbm/entity/train/EntityRailCarRidable.java b/src/main/java/com/hbm/entity/train/EntityRailCarRidable.java index 95dd63367a..4fdb73ec45 100644 --- a/src/main/java/com/hbm/entity/train/EntityRailCarRidable.java +++ b/src/main/java/com/hbm/entity/train/EntityRailCarRidable.java @@ -1,30 +1,107 @@ package com.hbm.entity.train; +import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.Vec3; import net.minecraft.world.World; public abstract class EntityRailCarRidable extends EntityRailCarBase { + public SeatDummyEntity[] passengerSeats; + public EntityRailCarRidable(World world) { super(world); + this.passengerSeats = new SeatDummyEntity[this.getPassengerSeats().length]; } @Override public boolean interactFirst(EntityPlayer player) { - if(this.riddenByEntity != null && this.riddenByEntity instanceof EntityPlayer && this.riddenByEntity != player) { - return true; - } else { - if(!this.worldObj.isRemote) { - player.mountEntity(this); + + if(worldObj.isRemote) return true; + + double nearestDist = Double.POSITIVE_INFINITY; + int nearestSeat = -1; + + Vec3[] seats = getPassengerSeats(); + for(int i = 0; i < seats.length; i++) { + + Vec3 seat = seats[i]; + if(seat == null) continue; + if(passengerSeats[i] != null) continue; + + seat.rotateAroundY((float) (-this.rotationYaw * Math.PI / 180)); + double x = posX + seat.xCoord; + double y = posY + seat.yCoord; + double z = posZ + seat.zCoord; + double dist = Vec3.createVectorHelper(player.posX - x, player.posY - y, player.posZ - z).lengthVector(); + + if(dist < nearestDist) { + nearestDist = dist; + nearestSeat = i; + } + } + + if(this.riddenByEntity == null) { + Vec3 seat = getRiderSeatPosition(); + seat.rotateAroundY((float) (-this.rotationYaw * Math.PI / 180)); + double x = posX + seat.xCoord; + double y = posY + seat.yCoord; + double z = posZ + seat.zCoord; + double dist = Vec3.createVectorHelper(player.posX - x, player.posY - y, player.posZ - z).lengthVector(); + + if(dist < nearestDist) { + nearestDist = dist; + nearestSeat = -1; } - return true; } + + if(nearestDist > 20) return true; + + if(nearestSeat == -1) { + player.mountEntity(this); + } else { + SeatDummyEntity dummySeat = new SeatDummyEntity(worldObj); + Vec3 passengerSeat = this.getPassengerSeats()[nearestSeat]; + passengerSeat.rotateAroundY((float) (-this.rotationYaw * Math.PI / 180)); + double x = posX + passengerSeat.xCoord; + double y = posY + passengerSeat.yCoord; + double z = posZ + passengerSeat.zCoord; + dummySeat.setPosition(x, y - 1, z); + passengerSeats[nearestSeat] = dummySeat; + worldObj.spawnEntityInWorld(dummySeat); + player.mountEntity(dummySeat); + } + + return true; } @Override public void onUpdate() { super.onUpdate(); + + if(!worldObj.isRemote) { + + Vec3[] seats = this.getPassengerSeats(); + for(int i = 0; i < passengerSeats.length; i++) { + SeatDummyEntity seat = passengerSeats[i]; + + if(seat != null) { + if(seat.riddenByEntity == null) { + passengerSeats[i] = null; + seat.setDead(); + } else { + Vec3 rot = seats[i]; + rot.rotateAroundY((float) (-this.rotationYaw * Math.PI / 180)); + double x = posX + rot.xCoord; + double y = posY + rot.yCoord; + double z = posZ + rot.zCoord; + seat.setPosition(x, y - 1, z); + seat.updateRiderPosition(); + } + } + } + } } @Override @@ -40,4 +117,21 @@ public void updateRiderPosition() { /** Returns a Vec3 showing the relative position from the driver to the core */ public abstract Vec3 getRiderSeatPosition(); + + public abstract Vec3[] getPassengerSeats(); + + public static class SeatDummyEntity extends Entity { + public SeatDummyEntity(World world) { super(world); this.setSize(0.5F, 0.1F);} + @Override protected void entityInit() { } + @Override protected void writeEntityToNBT(NBTTagCompound nbt) { } + @Override public boolean writeToNBTOptional(NBTTagCompound nbt) { return false; } + @Override public void readEntityFromNBT(NBTTagCompound nbt) { this.setDead(); } + + @Override + public void updateRiderPosition() { + if(this.riddenByEntity != null) { + this.riddenByEntity.setPosition(this.posX, this.posY + 1, this.posZ); + } + } + } } diff --git a/src/main/java/com/hbm/entity/train/TrainCargoTram.java b/src/main/java/com/hbm/entity/train/TrainCargoTram.java index 5f76989a4d..c18e6ab236 100644 --- a/src/main/java/com/hbm/entity/train/TrainCargoTram.java +++ b/src/main/java/com/hbm/entity/train/TrainCargoTram.java @@ -31,7 +31,7 @@ public TrainCargoTram(World world) { public double speed = 0; public static final double maxSpeed = 0.5; public static final double acceleration = 0.01; - public static final double deceleration = 0.75; + public static final double deceleration = 0.95; @Override public double getCurrentSpeed() { // in its current form, only call once per tick @@ -80,4 +80,17 @@ public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_) { return true; } + + @Override + public boolean shouldRiderSit() { + return true; + } + + @Override + public Vec3[] getPassengerSeats() { + return new Vec3[] { + Vec3.createVectorHelper(0.5, 1.75, -1.5), + Vec3.createVectorHelper(-0.5, 1.75, -1.5) + }; + } } diff --git a/src/main/java/com/hbm/lib/RefStrings.java b/src/main/java/com/hbm/lib/RefStrings.java index dcc814ea75..79c7e3689f 100644 --- a/src/main/java/com/hbm/lib/RefStrings.java +++ b/src/main/java/com/hbm/lib/RefStrings.java @@ -3,7 +3,7 @@ public class RefStrings { public static final String MODID = "hbm"; public static final String NAME = "Hbm's Nuclear Tech Mod"; - public static final String VERSION = "1.0.27 BETA (4585)"; + public static final String VERSION = "1.0.27 BETA (4592)"; //HBM's Beta Naming Convention: //V T (X) //V -> next release version diff --git a/src/main/java/com/hbm/main/MainRegistry.java b/src/main/java/com/hbm/main/MainRegistry.java index da251825c6..b90f1903d1 100644 --- a/src/main/java/com/hbm/main/MainRegistry.java +++ b/src/main/java/com/hbm/main/MainRegistry.java @@ -848,7 +848,7 @@ public static void PostLoad(FMLPostInitializationEvent PostEvent) { new OreCave(ModBlocks.stone_resource, 0).setThreshold(1.5D).setRangeMult(20).setYLevel(30).setMaxRange(20).withFluid(ModBlocks.sulfuric_acid_block); //sulfur new OreCave(ModBlocks.stone_resource, 1).setThreshold(1.75D).setRangeMult(20).setYLevel(25).setMaxRange(20); //asbestos new OreLayer3D(ModBlocks.stone_resource, EnumStoneType.HEMATITE.ordinal()); - new BiomeCave().setThreshold(1.5D).setRangeMult(20).setYLevel(40).setMaxRange(20); + //new BiomeCave().setThreshold(1.5D).setRangeMult(20).setYLevel(40).setMaxRange(20); //new OreLayer(Blocks.coal_ore, 0.2F).setThreshold(4).setRangeMult(3).setYLevel(70); Compat.handleRailcraftNonsense(); diff --git a/src/main/java/com/hbm/main/ModEventHandlerClient.java b/src/main/java/com/hbm/main/ModEventHandlerClient.java index 9393a59c81..c3efd654ec 100644 --- a/src/main/java/com/hbm/main/ModEventHandlerClient.java +++ b/src/main/java/com/hbm/main/ModEventHandlerClient.java @@ -210,7 +210,7 @@ public void onOverlayRender(RenderGameOverlayEvent.Pre event) { Minecraft.getMinecraft().renderEngine.bindTexture(Gui.icons); }*/ - List text = new ArrayList(); + /*List text = new ArrayList(); MovingObjectPosition pos = Library.rayTrace(player, 500, 1, false, true, false); for(int i = 0; i < 2; i++) if(pos != null && pos.typeOfHit == pos.typeOfHit.BLOCK) { @@ -273,7 +273,7 @@ public void onOverlayRender(RenderGameOverlayEvent.Pre event) { } while(distanceToCover != 0); ILookOverlay.printGeneric(event, "DEBUG", 0xffff00, 0x4040000, text); - } + }*/ } /// HANLDE ANIMATION BUSES /// diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachinePress.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachinePress.java index 354fef3208..5992877011 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachinePress.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachinePress.java @@ -124,7 +124,12 @@ public void updateEntity() { if(slots[0] != null && burnTime < 200 && TileEntityFurnace.getItemBurnTime(slots[0]) > 0) { // less than one operation stored? burn more fuel! burnTime += TileEntityFurnace.getItemBurnTime(slots[0]); - this.decrStackSize(0, 1); + + if(slots[0].stackSize == 1 && slots[0].getItem().hasContainerItem(slots[0])) { + slots[0] = slots[0].getItem().getContainerItem(slots[0]).copy(); + } else { + this.decrStackSize(0, 1); + } this.markChanged(); } diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityTesla.java b/src/main/java/com/hbm/tileentity/machine/TileEntityTesla.java index fcab378f77..f3c930d3e0 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityTesla.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityTesla.java @@ -125,14 +125,16 @@ public static List zap(World worldObj, double x, double y, double z, d continue; } - if(!(e instanceof EntityPlayer && ArmorUtil.checkForFaraday((EntityPlayer)e))) - if(e.attackEntityFrom(ModDamageSource.electricity, MathHelper.clamp_float(e.getMaxHealth() * 0.5F, 3, 20) / (float)targets.size())) - worldObj.playSoundAtEntity(e, "hbm:weapon.tesla", 1.0F, 1.0F); - if(e instanceof EntityCreeper) { ((EntityCreeper)e).getDataWatcher().updateObject(17, Byte.valueOf((byte)1)); + ret.add(new double[] {e.posX, e.posY + e.height / 2, e.posZ}); + continue; } + if(!(e instanceof EntityPlayer && ArmorUtil.checkForFaraday((EntityPlayer)e))) + if(e.attackEntityFrom(ModDamageSource.electricity, MathHelper.clamp_float(e.getMaxHealth() * 0.5F, 3, 20) / (float)targets.size())) + worldObj.playSoundAtEntity(e, "hbm:weapon.tesla", 1.0F, 1.0F); + double offset = 0; if(source != null && e instanceof EntityPlayer && worldObj.isRemote) diff --git a/src/main/resources/assets/hbm/lang/de_DE.lang b/src/main/resources/assets/hbm/lang/de_DE.lang index 5e7a1b6f3e..ad9fb7d740 100644 --- a/src/main/resources/assets/hbm/lang/de_DE.lang +++ b/src/main/resources/assets/hbm/lang/de_DE.lang @@ -504,9 +504,11 @@ entity.entity_ntm_radiation_blaze.name=Kernschmelze-Elementar entity.hbm.entity_ntm_ufo.name=Marsianisches Invasionsschiff entity.entity_mob_hunter_chopper.name=Jagdschrauber entity.entity_mob_mask_man.name=Maskenmann +entity.entity_mob_gold_creeper.name=Goldener Creeper entity.entity_mob_nuclear_creeper.name=Nuklearer Creeper entity.entity_mob_phosgene_creeper.name=Phosgen-Creeper entity.entity_mob_tainted_creeper.name=Verseuchter Creeper +entity.entity_mob_volatile_creeper.name=Instabiler Creeper entity.entity_taint_crab.name=Verseuchte Krabbe entity.entity_tesla_crab.name=Tesla-Krabbe entity.hbm.entity_balls_o_tron.name=Balls-O-Tron Prime diff --git a/src/main/resources/assets/hbm/lang/en_US.lang b/src/main/resources/assets/hbm/lang/en_US.lang index c35075e337..e2b518d48d 100644 --- a/src/main/resources/assets/hbm/lang/en_US.lang +++ b/src/main/resources/assets/hbm/lang/en_US.lang @@ -950,9 +950,11 @@ entity.entity_ntm_radiation_blaze.name=Meltdown Elemental entity.hbm.entity_ntm_ufo.name=Martian Invasion Ship entity.entity_mob_hunter_chopper.name=Hunter Chopper entity.entity_mob_mask_man.name=Mask Man +entity.entity_mob_gold_creeper.name=Golden Creeper entity.entity_mob_nuclear_creeper.name=Nuclear Creeper entity.entity_mob_phosgene_creeper.name=Phosgene Creeper entity.entity_mob_tainted_creeper.name=Tainted Creeper +entity.entity_mob_volatile_creeper.name=Volatile Creeper entity.entity_taint_crab.name=Taint Crab entity.entity_tesla_crab.name=Tesla Crab entity.hbm.entity_balls_o_tron.name=Balls-O-Tron Prime diff --git a/src/main/resources/assets/hbm/textures/models/tank/tank_CHOLERSTEROL.png b/src/main/resources/assets/hbm/textures/models/tank/tank_CHOLESTEROL.png similarity index 100% rename from src/main/resources/assets/hbm/textures/models/tank/tank_CHOLERSTEROL.png rename to src/main/resources/assets/hbm/textures/models/tank/tank_CHOLESTEROL.png