Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FloorMarker emits a weak redstone signal when elevator is at selected floor. #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,23 @@ public IIcon[] registerSideIcons(IIconRegister iconRegister) {
return null;
}

@Override
public boolean canProvidePower() {
return true;
}

@Override
public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) {


TileEntity tile = world.getTileEntity(x,
y,
z);
if (tile instanceof TileEntityFloorMarker) {
if (((TileEntityFloorMarker) tile).atFloor) {
return 3;
}
}
if (tile instanceof TileEntityTransportBase) {

ItemStack itemstack = ((TileEntityTransportBase) tile).getCamoItem();
Expand All @@ -152,6 +162,11 @@ public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int s
TileEntity tile = world.getTileEntity(x,
y,
z);
if (tile instanceof TileEntityFloorMarker) {
if (((TileEntityFloorMarker) tile).atFloor) {
return 3;
}
}
if (tile instanceof TileEntityTransportBase) {

ItemStack itemstack = ((TileEntityTransportBase) tile).getCamoItem();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.MathHelper;
import net.slimevoid.dynamictransport.blocks.BlockTransportBase;
import net.slimevoid.dynamictransport.core.lib.BlockLib;
import net.slimevoid.dynamictransport.core.lib.ConfigurationLib;
import net.slimevoid.dynamictransport.entities.EntityMasterElevator;
Expand Down Expand Up @@ -397,6 +398,14 @@ private void doCallElevator(int i, String floorname) {
this.boundElevatorBlocks
);

for (ChunkCoordinates boundBlock : this.boundMarkerBlocks) {
TileEntity tile = this.worldObj.getTileEntity(boundBlock.posX, boundBlock.posY, boundBlock.posZ);
if (tile != null && tile instanceof TileEntityFloorMarker) {
TileEntityFloorMarker marker = (TileEntityFloorMarker) tile;
marker.setActive(false);
worldObj.notifyBlockChange(boundBlock.posX, boundBlock.posY, boundBlock.posZ, worldObj.getBlock(boundBlock.posX, boundBlock.posY, boundBlock.posZ));
}
}

}

Expand Down Expand Up @@ -573,7 +582,17 @@ public void elevatorArrived(int destination) {
this.floorSpool.get(nextFloor));
}
}

for (ChunkCoordinates boundBlock : this.boundMarkerBlocks) {
TileEntity tile = this.worldObj.getTileEntity(boundBlock.posX, boundBlock.posY, boundBlock.posZ);
if (tile != null && tile instanceof TileEntityFloorMarker) {
TileEntityFloorMarker marker = (TileEntityFloorMarker) tile;
int floorY = marker.getFloorY();
if (floorY == destination) {
marker.setActive(true);
}
worldObj.notifyBlockChange(boundBlock.posX, boundBlock.posY, boundBlock.posZ, worldObj.getBlock(boundBlock.posX, boundBlock.posY, boundBlock.posZ));
}
}
}

@SuppressWarnings("UnusedDeclaration")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class TileEntityFloorMarker extends TileEntityTransportBase {
private String floorName;
private boolean Powered = false;
private int yOffset = -2;
public boolean atFloor = false;

public ChunkCoordinates getParentChunkCoords() {
return this.parentTransportBase;
Expand Down Expand Up @@ -152,7 +153,8 @@ public void writeToNBT(NBTTagCompound nbttagcompound) {
yOffset);
nbttagcompound.setBoolean("Powered",
this.Powered);

nbttagcompound.setBoolean("atFloor",
this.atFloor);
}

@Override
Expand All @@ -164,6 +166,7 @@ public void readFromNBT(NBTTagCompound nbttagcompound) {

this.yOffset = nbttagcompound.getInteger("yOffset");
this.Powered = nbttagcompound.getBoolean("Powered");
this.atFloor = nbttagcompound.getBoolean("atFloor");
}

public void removeParent() {
Expand Down Expand Up @@ -246,4 +249,8 @@ public Packet getDescriptionPacket()
this.writeToNBT(nbttagcompound);
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 2, nbttagcompound);
}

public void setActive(boolean flag) {
this.atFloor = flag;
}
}