mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-08-10 17:55:44 +00:00
Merge pull request #3108 from APie357/master
add ror support for cargo elevator
This commit is contained in:
commit
0ceeb45494
@ -2,6 +2,7 @@ package com.hbm.tileentity.machine;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import api.hbm.redstoneoverradio.IRORInteractive;
|
||||||
import com.hbm.blocks.BlockDummyable;
|
import com.hbm.blocks.BlockDummyable;
|
||||||
import com.hbm.blocks.ModBlocks;
|
import com.hbm.blocks.ModBlocks;
|
||||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||||
@ -16,16 +17,16 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
|
|
||||||
public class TileEntityCargoElevator extends TileEntityLoadedBase {
|
public class TileEntityCargoElevator extends TileEntityLoadedBase implements IRORInteractive {
|
||||||
|
|
||||||
public int height = 0;
|
public int height = 0;
|
||||||
|
|
||||||
|
public int targetExtension;
|
||||||
public double extension;
|
public double extension;
|
||||||
public double prevExtension;
|
public double prevExtension;
|
||||||
public double syncExtension;
|
public double syncExtension;
|
||||||
private int sync;
|
private int sync;
|
||||||
|
|
||||||
public boolean isExtending;
|
|
||||||
public static final double speed = 2D / 20D; // 2 blocks per second
|
public static final double speed = 2D / 20D; // 2 blocks per second
|
||||||
public boolean renderPlatform = false;
|
public boolean renderPlatform = false;
|
||||||
|
|
||||||
@ -49,13 +50,14 @@ public class TileEntityCargoElevator extends TileEntityLoadedBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.isExtending && this.extension < this.height) {
|
if (this.extension < targetExtension) { // go up
|
||||||
this.extension += this.speed;
|
this.extension += speed;
|
||||||
|
this.extension = MathHelper.clamp_double(this.extension, 0, targetExtension);
|
||||||
|
} else if (this.extension > targetExtension) { // go down
|
||||||
|
this.extension -= speed;
|
||||||
|
this.extension = MathHelper.clamp_double(this.extension, targetExtension, this.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!this.isExtending && this.extension > 0) {
|
|
||||||
this.extension -= this.speed;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.extension = MathHelper.clamp_double(this.extension, 0, this.height);
|
this.extension = MathHelper.clamp_double(this.extension, 0, this.height);
|
||||||
|
|
||||||
@ -91,13 +93,10 @@ public class TileEntityCargoElevator extends TileEntityLoadedBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void toggleElevator() {
|
public void toggleElevator() {
|
||||||
|
if (targetExtension == 0) {
|
||||||
if(this.extension >= this.height) {
|
targetExtension = this.height;
|
||||||
this.isExtending = false;
|
} else {
|
||||||
}
|
targetExtension = 0;
|
||||||
|
|
||||||
if(this.extension <= 0) {
|
|
||||||
this.isExtending = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,7 +125,7 @@ public class TileEntityCargoElevator extends TileEntityLoadedBase {
|
|||||||
super.readFromNBT(nbt);
|
super.readFromNBT(nbt);
|
||||||
|
|
||||||
this.extension = nbt.getDouble("extension");
|
this.extension = nbt.getDouble("extension");
|
||||||
this.isExtending = nbt.getBoolean("isExtending");
|
this.targetExtension = nbt.getInteger("targetExtension");
|
||||||
this.height = nbt.getInteger("height");
|
this.height = nbt.getInteger("height");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +134,7 @@ public class TileEntityCargoElevator extends TileEntityLoadedBase {
|
|||||||
super.writeToNBT(nbt);
|
super.writeToNBT(nbt);
|
||||||
|
|
||||||
nbt.setDouble("extension", extension);
|
nbt.setDouble("extension", extension);
|
||||||
nbt.setBoolean("isExtending", isExtending);
|
nbt.setInteger("targetExtension", this.targetExtension);
|
||||||
nbt.setInteger("height", height);
|
nbt.setInteger("height", height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,4 +165,22 @@ public class TileEntityCargoElevator extends TileEntityLoadedBase {
|
|||||||
public double getMaxRenderDistanceSquared() {
|
public double getMaxRenderDistanceSquared() {
|
||||||
return 65536.0D;
|
return 65536.0D;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String runRORFunction(String name, String[] params) {
|
||||||
|
if ((PREFIX_FUNCTION + "setextension").equals(name) && params.length > 0) {
|
||||||
|
targetExtension = IRORInteractive.parseInt(params[0], 0, height);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getFunctionInfo() {
|
||||||
|
return new String[]{
|
||||||
|
PREFIX_VALUE + "extension",
|
||||||
|
PREFIX_FUNCTION + "setextension"
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user