Skip to content

Commit

Permalink
tram passenger seats
Browse files Browse the repository at this point in the history
  • Loading branch information
HbmMods committed May 7, 2023
1 parent bfb1334 commit 7336757
Show file tree
Hide file tree
Showing 15 changed files with 161 additions and 33 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -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),\
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/hbm/entity/EntityMappings.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
15 changes: 13 additions & 2 deletions src/main/java/com/hbm/entity/mob/EntityCreeperGold.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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());
Expand All @@ -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);
}
}
}
12 changes: 10 additions & 2 deletions src/main/java/com/hbm/entity/mob/EntityCreeperVolatile.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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());
Expand All @@ -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);
}
}
11 changes: 0 additions & 11 deletions src/main/java/com/hbm/entity/train/EntityRailCarBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}
}

Expand Down
106 changes: 100 additions & 6 deletions src/main/java/com/hbm/entity/train/EntityRailCarRidable.java
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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);
}
}
}
}
15 changes: 14 additions & 1 deletion src/main/java/com/hbm/entity/train/TrainCargoTram.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
};
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/hbm/lib/RefStrings.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/hbm/main/MainRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/hbm/main/ModEventHandlerClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public void onOverlayRender(RenderGameOverlayEvent.Pre event) {
Minecraft.getMinecraft().renderEngine.bindTexture(Gui.icons);
}*/

List<String> text = new ArrayList();
/*List<String> 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) {
Expand Down Expand Up @@ -273,7 +273,7 @@ public void onOverlayRender(RenderGameOverlayEvent.Pre event) {
} while(distanceToCover != 0);
ILookOverlay.printGeneric(event, "DEBUG", 0xffff00, 0x4040000, text);
}
}*/
}

/// HANLDE ANIMATION BUSES ///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
10 changes: 6 additions & 4 deletions src/main/java/com/hbm/tileentity/machine/TileEntityTesla.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,16 @@ public static List<double[]> 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)
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/hbm/lang/de_DE.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/hbm/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7336757

Please sign in to comment.