Fix some warnings.
This commit is contained in:
parent
9cb90bb56d
commit
cb6c6337a8
5 changed files with 33 additions and 21 deletions
|
@ -56,7 +56,6 @@ public abstract class MultiblockControllerBase {
|
||||||
Disassembled, Assembled, Paused
|
Disassembled, Assembled, Paused
|
||||||
}
|
}
|
||||||
|
|
||||||
;
|
|
||||||
protected AssemblyState assemblyState;
|
protected AssemblyState assemblyState;
|
||||||
|
|
||||||
public HashSet<IMultiblockPart> connectedParts;
|
public HashSet<IMultiblockPart> connectedParts;
|
||||||
|
@ -398,7 +397,6 @@ public abstract class MultiblockControllerBase {
|
||||||
* now is, assemble the machine. If the machine was whole, but no longer is,
|
* now is, assemble the machine. If the machine was whole, but no longer is,
|
||||||
* disassemble the machine.
|
* disassemble the machine.
|
||||||
*
|
*
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public void checkIfMachineIsWhole() {
|
public void checkIfMachineIsWhole() {
|
||||||
AssemblyState oldState = this.assemblyState;
|
AssemblyState oldState = this.assemblyState;
|
||||||
|
@ -494,15 +492,16 @@ public abstract class MultiblockControllerBase {
|
||||||
* @param otherController The controller consuming this controller.
|
* @param otherController The controller consuming this controller.
|
||||||
*/
|
*/
|
||||||
private void _onAssimilated(MultiblockControllerBase otherController) {
|
private void _onAssimilated(MultiblockControllerBase otherController) {
|
||||||
if (referenceCoord != null) {
|
if (referenceCoord == null) { return; }
|
||||||
if (this.worldObj.isChunkLoaded(this.referenceCoord)) {
|
|
||||||
|
if (WorldUtils.isChunkLoaded(worldObj, referenceCoord)) {
|
||||||
BlockEntity te = this.worldObj.getBlockEntity(referenceCoord);
|
BlockEntity te = this.worldObj.getBlockEntity(referenceCoord);
|
||||||
if (te instanceof IMultiblockPart) {
|
if (te instanceof IMultiblockPart) {
|
||||||
((IMultiblockPart) te).forfeitMultiblockSaveDelegate();
|
((IMultiblockPart) te).forfeitMultiblockSaveDelegate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.referenceCoord = null;
|
this.referenceCoord = null;
|
||||||
}
|
|
||||||
connectedParts.clear();
|
connectedParts.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -862,7 +861,7 @@ public abstract class MultiblockControllerBase {
|
||||||
* Called when this machine may need to check for blocks that are no longer
|
* Called when this machine may need to check for blocks that are no longer
|
||||||
* physically connected to the reference coordinate.
|
* physically connected to the reference coordinate.
|
||||||
*
|
*
|
||||||
* @return
|
* @return Set with removed parts
|
||||||
*/
|
*/
|
||||||
public Set<IMultiblockPart> checkForDisconnections() {
|
public Set<IMultiblockPart> checkForDisconnections() {
|
||||||
if (!this.shouldCheckForDisconnections) {
|
if (!this.shouldCheckForDisconnections) {
|
||||||
|
@ -886,7 +885,7 @@ public abstract class MultiblockControllerBase {
|
||||||
|
|
||||||
for (IMultiblockPart part : connectedParts) {
|
for (IMultiblockPart part : connectedParts) {
|
||||||
pos = part.getWorldLocation();
|
pos = part.getWorldLocation();
|
||||||
if (!this.worldObj.isChunkLoaded(pos) || part.isInvalid()) {
|
if (!WorldUtils.isChunkLoaded(worldObj, pos) || part.isInvalid()) {
|
||||||
deadParts.add(part);
|
deadParts.add(part);
|
||||||
onDetachBlock(part);
|
onDetachBlock(part);
|
||||||
continue;
|
continue;
|
||||||
|
@ -927,7 +926,7 @@ public abstract class MultiblockControllerBase {
|
||||||
// coord's part
|
// coord's part
|
||||||
IMultiblockPart part;
|
IMultiblockPart part;
|
||||||
LinkedList<IMultiblockPart> partsToCheck = new LinkedList<>();
|
LinkedList<IMultiblockPart> partsToCheck = new LinkedList<>();
|
||||||
IMultiblockPart[] nearbyParts = null;
|
IMultiblockPart[] nearbyParts;
|
||||||
int visitedParts = 0;
|
int visitedParts = 0;
|
||||||
|
|
||||||
partsToCheck.add(referencePart);
|
partsToCheck.add(referencePart);
|
||||||
|
@ -992,7 +991,7 @@ public abstract class MultiblockControllerBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (IMultiblockPart part : connectedParts) {
|
for (IMultiblockPart part : connectedParts) {
|
||||||
if (this.worldObj.isChunkLoaded(part.getWorldLocation())) {
|
if (WorldUtils.isChunkLoaded(worldObj, part.getWorldLocation())) {
|
||||||
onDetachBlock(part);
|
onDetachBlock(part);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1017,7 +1016,7 @@ public abstract class MultiblockControllerBase {
|
||||||
|
|
||||||
for (IMultiblockPart part : connectedParts) {
|
for (IMultiblockPart part : connectedParts) {
|
||||||
pos = part.getWorldLocation();
|
pos = part.getWorldLocation();
|
||||||
if (part.isInvalid() || !this.worldObj.isChunkLoaded(pos)) {
|
if (part.isInvalid() || !WorldUtils.isChunkLoaded(worldObj, pos)) {
|
||||||
// Chunk is unloading, skip this coord to prevent chunk thrashing
|
// Chunk is unloading, skip this coord to prevent chunk thrashing
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ import net.minecraft.util.math.ChunkPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
import reborncore.RebornCore;
|
import reborncore.RebornCore;
|
||||||
|
import reborncore.common.util.WorldUtils;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
@ -140,7 +141,7 @@ public class MultiblockWorldRegistry {
|
||||||
// controller
|
// controller
|
||||||
for (IMultiblockPart orphan : orphansToProcess) {
|
for (IMultiblockPart orphan : orphansToProcess) {
|
||||||
coord = orphan.getWorldLocation();
|
coord = orphan.getWorldLocation();
|
||||||
if (!this.worldObj.isChunkLoaded(coord)) {
|
if (!WorldUtils.isChunkLoaded(worldObj, coord)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,7 +319,7 @@ public class MultiblockWorldRegistry {
|
||||||
public void onPartAdded(IMultiblockPart part) {
|
public void onPartAdded(IMultiblockPart part) {
|
||||||
BlockPos pos = part.getWorldLocation();
|
BlockPos pos = part.getWorldLocation();
|
||||||
|
|
||||||
if (!this.worldObj.isChunkLoaded(pos)) {
|
if (!WorldUtils.isChunkLoaded(worldObj, pos)) {
|
||||||
// Part goes into the waiting-for-chunk-load list
|
// Part goes into the waiting-for-chunk-load list
|
||||||
Set<IMultiblockPart> partSet;
|
Set<IMultiblockPart> partSet;
|
||||||
int chunkHash = new ChunkPos(pos).hashCode();
|
int chunkHash = new ChunkPos(pos).hashCode();
|
||||||
|
|
|
@ -46,6 +46,7 @@ import reborncore.common.blockentity.FluidConfiguration;
|
||||||
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
||||||
import reborncore.common.blockentity.SlotConfiguration;
|
import reborncore.common.blockentity.SlotConfiguration;
|
||||||
import reborncore.common.chunkloading.ChunkLoaderManager;
|
import reborncore.common.chunkloading.ChunkLoaderManager;
|
||||||
|
import reborncore.common.util.WorldUtils;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ import net.minecraft.entity.ItemEntity;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.ChunkSectionPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
@ -45,10 +46,18 @@ public class WorldUtils {
|
||||||
world.updateListeners(pos, state, state, 3);
|
world.updateListeners(pos, state, state, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean chunkExists(World world, int x, int z) {
|
/**
|
||||||
return world.isChunkLoaded(new BlockPos(x << 4, 64, z << 4));
|
* Checks if chunk is loaded using proper chunk manager
|
||||||
|
*
|
||||||
|
* @param world World object
|
||||||
|
* @param pos BlockPos X and Z coordinates to check
|
||||||
|
* @return boolean True if chunk is loaded
|
||||||
|
*/
|
||||||
|
public static boolean isChunkLoaded(World world, BlockPos pos){
|
||||||
|
return world.getChunkManager().isChunkLoaded(ChunkSectionPos.getSectionCoord(pos.getX()), ChunkSectionPos.getSectionCoord(pos.getZ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void dropItem(ItemStack itemStack, World world, BlockPos pos) {
|
public static void dropItem(ItemStack itemStack, World world, BlockPos pos) {
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
|
|
||||||
|
|
|
@ -498,7 +498,7 @@ public class TRContent {
|
||||||
|
|
||||||
public static ItemConvertible[] getCasings() {
|
public static ItemConvertible[] getCasings() {
|
||||||
return Arrays.stream(MachineBlocks.values())
|
return Arrays.stream(MachineBlocks.values())
|
||||||
.map((Function<MachineBlocks, ItemConvertible>) machineBlocks -> () -> machineBlocks.casing.asItem())
|
.map((Function<MachineBlocks, ItemConvertible>) machineBlocks -> machineBlocks.casing::asItem)
|
||||||
.toArray(ItemConvertible[]::new);
|
.toArray(ItemConvertible[]::new);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -855,8 +855,10 @@ public class TRContent {
|
||||||
if (blockEntity instanceof PowerAcceptorBlockEntity) {
|
if (blockEntity instanceof PowerAcceptorBlockEntity) {
|
||||||
powerAcceptor = (PowerAcceptorBlockEntity) blockEntity;
|
powerAcceptor = (PowerAcceptorBlockEntity) blockEntity;
|
||||||
}
|
}
|
||||||
|
if (handler != null) {
|
||||||
handler.addSpeedMulti(TechRebornConfig.overclockerSpeed);
|
handler.addSpeedMulti(TechRebornConfig.overclockerSpeed);
|
||||||
handler.addPowerMulti(TechRebornConfig.overclockerPower);
|
handler.addPowerMulti(TechRebornConfig.overclockerPower);
|
||||||
|
}
|
||||||
if (powerAcceptor != null) {
|
if (powerAcceptor != null) {
|
||||||
powerAcceptor.extraPowerInput += powerAcceptor.getMaxInput(EnergySide.UNKNOWN);
|
powerAcceptor.extraPowerInput += powerAcceptor.getMaxInput(EnergySide.UNKNOWN);
|
||||||
powerAcceptor.extraPowerStorage += powerAcceptor.getBaseMaxPower();
|
powerAcceptor.extraPowerStorage += powerAcceptor.getBaseMaxPower();
|
||||||
|
|
Loading…
Reference in a new issue