Skip to content

Commit

Permalink
fixed 1.12 porting differences.
Browse files Browse the repository at this point in the history
  • Loading branch information
EternalBlueFlame committed Aug 8, 2023
1 parent c45b4cb commit bf819cb
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 32 deletions.
15 changes: 6 additions & 9 deletions src/main/java/ebf/tim/blocks/TileSwitch.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
import fexcraft.tmt.slim.Vec3f;
import net.minecraft.entity.item.EntityMinecart;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ITickable;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.*;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3i;

import java.util.List;
Expand Down Expand Up @@ -176,8 +174,8 @@ public void tickTile(){
public int checkBlockPower(int[] ... offset){
int signalStrength=0;
for(int[] o : offset) {
signalStrength = getWorld().getStrongPower(pos.add(o[0], o[1], o[2]));
if (signalStrength == 0 && getWorld().isBlockPowered(pos.add(o[0], o[1], o[2]))) {
signalStrength = getWorld().getStrongPower(getPos().add(o[0], o[1], o[2]));
if (signalStrength == 0 && getWorld().isBlockPowered(getPos().add(o[0], o[1], o[2]))) {
return 15;
} else if(signalStrength!=0) {
return signalStrength;
Expand All @@ -189,11 +187,10 @@ public int checkBlockPower(int[] ... offset){
public int checkBlockPower(int[] offset, int depth){
int signalStrength=0;
for(int o =-1;o<depth-1;o++) {
signalStrength = worldObj.getBlockPowerInput(xCoord + offset[0], yCoord + offset[1]+o, zCoord + offset[2]);
signalStrength = getWorld().getStrongPower(getPos().add(offset[0],offset[1],offset[2]));
if(signalStrength==0){
//1.12 use getMaxCurrentStrength
signalStrength = CommonUtil.getBlockAt(getWorld(),xCoord + offset[0], yCoord + offset[1]+o, zCoord + offset[2])
.isProvidingStrongPower(getWorld(),xCoord + offset[0], yCoord + offset[1]+o, zCoord + offset[2],0);
signalStrength = getWorld().getBlockState(pos).getWeakPower(getWorld(),pos.add(offset[0],offset[1],offset[2]), EnumFacing.DOWN);
//the 0 as the last arg is something with direction i think.
}
if(signalStrength!=0) {
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/ebf/tim/entities/EntityBogie.java
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ private void moveOffRail(){
private void loopVanilla(GenericRailTransport host, double moveLength, BlockRailBase block){

//try to adhere to limiter track
railmax = block.getRailMaxSpeed(getWorld(),this,xFloor, yFloor, zFloor);
railmax = block.getRailMaxSpeed(getWorld(),this,new BlockPos(xFloor, yFloor, zFloor));
Block blockUp;
if(railmax!=0.4f){
moveLength=Math.min(moveLength,railmax);
Expand Down Expand Up @@ -348,15 +348,16 @@ private void loopVanilla(GenericRailTransport host, double moveLength, BlockRail
block = (BlockRailBase) blockNext;
//do the rail functions.
if(shouldDoRailFunctions()) {
block.onMinecartPass(getWorld(), this, xFloor, yFloor, zFloor);
block.onMinecartPass(getWorld(), this, new BlockPos(xFloor, yFloor, zFloor));
}
//get the direction of the rail from it's metadata
railMetadata = CommonUtil.getRailMeta(getWorld(), this, xFloor, yFloor, zFloor);
}
//get the direction of the rail from it's metadata
else if (getWorld().getTileEntity(xFloor, yFloor, zFloor) instanceof ITrackTile && (((ITrackTile)getWorld().getTileEntity(xFloor, yFloor, zFloor)).getTrackInstance() instanceof ITrackSwitch)){
/*TODO:railcraft support
else if (getWorld().getTileEntity(new BlockPos(xFloor, yFloor, zFloor)) instanceof ITrackTile && (((ITrackTile)getWorld().getTileEntity(xFloor, yFloor, zFloor)).getTrackInstance() instanceof ITrackSwitch)){
railMetadata = CommonUtil.getRailMeta(getWorld(),this,xFloor, yFloor, zFloor);//railcraft support
}
}*/
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/ebf/tim/entities/EntityTrainCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public int getAccelerator(){
*/
@Override
public void onUpdate() {
if(!worldObj.isRemote && backBogie != null && frontBogie != null) {
if(!getWorld().isRemote && backBogie != null && frontBogie != null) {
cachedVectors[2].xCoord = 0;
//twice a second, re-calculate the speed.
if (getAccelerator()!=0 && getBoolean(boolValues.RUNNING)) {
Expand All @@ -185,7 +185,7 @@ public void onUpdate() {
}
} else {
accelerator = 0;
this.dataWatcher.updateObject(18, getAccelerator());
this.dataManager.set(ACCELERATOR, getAccelerator());
}

if(getAccelerator()==0 && getBoolean(boolValues.BRAKE) && getVelocity()==0){
Expand Down Expand Up @@ -290,7 +290,7 @@ public boolean interact(int player, boolean isFront, boolean isBack, int key) {
accelerator--;
}
updateLinks();
this.dataWatcher.updateObject(18, accelerator);
this.dataManager.set(ACCELERATOR, accelerator);
}
return true;
}case 3:{ //increase speed
Expand All @@ -305,7 +305,7 @@ public boolean interact(int player, boolean isFront, boolean isBack, int key) {
accelerator++;
}
updateLinks();
this.dataWatcher.updateObject(18, accelerator);
this.dataManager.set(ACCELERATOR, accelerator);
}
return true;
} case 16:{//reset speed
Expand All @@ -316,7 +316,7 @@ public boolean interact(int player, boolean isFront, boolean isBack, int key) {
}
accelerator = 0;
updateLinks();
this.dataWatcher.updateObject(18, accelerator);
this.dataManager.set(ACCELERATOR, accelerator);
}
return true;
} case 11:{//TC control forward
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ebf/tim/entities/GenericRailTransport.java
Original file line number Diff line number Diff line change
Expand Up @@ -1633,7 +1633,7 @@ public void manageLink(GenericRailTransport other) {
double vecZ = other.posZ - posZ;


double springDist = MathHelper.sqrt_double(vecX * vecX + vecZ * vecZ)
double springDist = MathHelper.sqrt(vecX * vecX + vecZ * vecZ)
-(getOptimalDistance(other)+other.getOptimalDistance(this));

if(getVelocity()>0.3) {
Expand Down
17 changes: 9 additions & 8 deletions src/main/java/ebf/tim/render/RenderWagon.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,32 +53,33 @@ public ResourceLocation getEntityTexture(GenericRailTransport entity){
return null;
}

//manages culling, mostly just breaks stuff, leave to return true.
@Override
public boolean shouldRender(GenericRailTransport entity, ICamera camera, double camX, double camY, double camZ) {
return true;
}
/**
* <h3>base render extension</h3>
* acts as a redirect for the base render function to our own function.
* This is just to do typecasting and a few calculations beforehand so we only need to do them once per render.
* todo: 1.9+ should support Entity<t zextends GenericRailTransport> so this typecasting method should be completely useless then.
*/
/*@Override
public void doRender(Entity entity, double x, double y, double z, float yaw, float partialTick){
if (entity instanceof GenericRailTransport){
render((GenericRailTransport) entity, x, y, z, entity.rotationYaw + CommonUtil.wrapAngleTo180(entity.rotationYaw - entity.prevRotationYaw) * partialTick,
((GenericRailTransport) entity).backBogie==null);
}
@Override
public void doRender(GenericRailTransport entity, double x, double y, double z, float yaw, float partialTick){
render(entity, x, y, z, entity.rotationYaw + CommonUtil.wrapAngleTo180(entity.rotationYaw - entity.prevRotationYaw) * partialTick,
entity.backBogie==null);
}

@Override
public void doRenderShadowAndFire(Entity entityIn, double x, double y, double z, float yaw, float partialTicks)
{}

public void render(GenericRailTransport entity, double x, double y, double z, float yaw, boolean isPaintBucket) {
renderBlocks=field_147909_c;
doRender(entity,x,y,z,yaw,entity.backBogie!=null?entity.backBogie.yOffset:0, isPaintBucket, null, this);
}


public void render(GenericRailTransport entity, double x, double y, double z, float yaw, boolean isPaintBucket, TransportSkin textureURI) {
renderBlocks=field_147909_c;
doRender(entity,x,y,z,yaw,entity.backBogie !=null?entity.backBogie.yOffset:0, isPaintBucket, textureURI, this);
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/ebf/tim/utility/FuelHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public void manageSteam(EntityTrainCore train){
train.fill(getUseableFluid(train.waterSlot().getSlotID(),train), true);
if (!train.getBoolean(GenericRailTransport.boolValues.CREATIVE)) {
train.getSlotIndexByID(train.waterSlot().getSlotID()).decrStackSize(1);
train.addItem(new ItemStack(Items.bucket));
train.addItem(new ItemStack(Items.BUCKET));
train.markDirty();
}
}
Expand Down Expand Up @@ -419,11 +419,11 @@ public static void manageElectricFuel(EntityTrainCore train){

public static void manageTanker(GenericRailTransport transport){
if (getUseableFluid(transport.tankerInputSlot().getSlotID(),transport) !=null &&
transport.fill(null,getUseableFluid(transport.tankerInputSlot().getSlotID(),transport),false)==getUseableFluid(transport.tankerInputSlot().getSlotID(),transport).amount) {
transport.fill(null,getUseableFluid(transport.tankerInputSlot().getSlotID(),transport), true);
transport.fill(getUseableFluid(transport.tankerInputSlot().getSlotID(),transport),false)==getUseableFluid(transport.tankerInputSlot().getSlotID(),transport).amount) {
transport.fill(getUseableFluid(transport.tankerInputSlot().getSlotID(),transport), true);
if (!transport.getBoolean(GenericRailTransport.boolValues.CREATIVE)) {
transport.getSlotIndexByID(transport.tankerInputSlot().getSlotID()).decrStackSize(1);
transport.addItem(new ItemStack(Items.bucket));
transport.addItem(new ItemStack(Items.BUCKET));
}
}
//attempt to fill any buckets in the drain slot
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ebf/tim/utility/HitboxDynamic.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public HitboxDynamic(float depth, float height, float width, GenericRailTranspor
width*0.5,height,width*0.5));
c.setPosition(entity.posX, entity.posY, entity.posZ);
interactionBoxes.add(c);
entity.worldObj.spawnEntityInWorld(c);
entity.getWorld().spawnEntity(c);
if(front==null){
front=c;
} else{
Expand Down

0 comments on commit bf819cb

Please sign in to comment.