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

fix flood lights te issues #6

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,16 @@ public void setLight(int x, int y, int z) {
}
if (worldObj.setBlock(x, y, z, ModBlocks.blockPhantomLight)) {
TileEntity tile = worldObj.getTileEntity(x, y, z);
if (tile instanceof TileEntityPhantomLight) {
TileEntityPhantomLight light = (TileEntityPhantomLight) tile;
light.addSource(this.xCoord, this.yCoord, this.zCoord);
worldObj.markBlockRangeForRenderUpdate(x, y, z, x, y, z);
if (!(tile instanceof TileEntityPhantomLight)) {
tile = new TileEntityPhantomLight();
worldObj.setTileEntity(x, y, z, tile);
}
return;
TileEntityPhantomLight light = (TileEntityPhantomLight) tile;
light.addSource(this.xCoord, this.yCoord, this.zCoord);
worldObj.markBlockRangeForRenderUpdate(x, y, z, x, y, z);
} else {
this.toggleUpdateRun();
}
this.toggleUpdateRun();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ public void removeSource(int x, int y, int z) {
}

public void updateAllSources() {
for (int[] source : sources) {
// Create a copy of sources, because sources can be modified while we update it here.
ArrayList<int[]> sourcesCopy = new ArrayList<>();
sourcesCopy.addAll(sources);

for (int[] source : sourcesCopy) {
TileEntity te = worldObj.getTileEntity(source[0], source[1], source[2]);
if (te != null && te instanceof TileEntityMetaFloodlight) {
((TileEntityMetaFloodlight) te).toggleUpdateRun();
Expand Down
Loading