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
|
||||
}
|
||||
|
||||
;
|
||||
protected AssemblyState assemblyState;
|
||||
|
||||
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,
|
||||
* disassemble the machine.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public void checkIfMachineIsWhole() {
|
||||
AssemblyState oldState = this.assemblyState;
|
||||
|
@ -494,15 +492,16 @@ public abstract class MultiblockControllerBase {
|
|||
* @param otherController The controller consuming this controller.
|
||||
*/
|
||||
private void _onAssimilated(MultiblockControllerBase otherController) {
|
||||
if (referenceCoord != null) {
|
||||
if (this.worldObj.isChunkLoaded(this.referenceCoord)) {
|
||||
if (referenceCoord == null) { return; }
|
||||
|
||||
if (WorldUtils.isChunkLoaded(worldObj, referenceCoord)) {
|
||||
BlockEntity te = this.worldObj.getBlockEntity(referenceCoord);
|
||||
if (te instanceof IMultiblockPart) {
|
||||
((IMultiblockPart) te).forfeitMultiblockSaveDelegate();
|
||||
}
|
||||
}
|
||||
this.referenceCoord = null;
|
||||
}
|
||||
|
||||
connectedParts.clear();
|
||||
}
|
||||
|
||||
|
@ -862,7 +861,7 @@ public abstract class MultiblockControllerBase {
|
|||
* Called when this machine may need to check for blocks that are no longer
|
||||
* physically connected to the reference coordinate.
|
||||
*
|
||||
* @return
|
||||
* @return Set with removed parts
|
||||
*/
|
||||
public Set<IMultiblockPart> checkForDisconnections() {
|
||||
if (!this.shouldCheckForDisconnections) {
|
||||
|
@ -886,7 +885,7 @@ public abstract class MultiblockControllerBase {
|
|||
|
||||
for (IMultiblockPart part : connectedParts) {
|
||||
pos = part.getWorldLocation();
|
||||
if (!this.worldObj.isChunkLoaded(pos) || part.isInvalid()) {
|
||||
if (!WorldUtils.isChunkLoaded(worldObj, pos) || part.isInvalid()) {
|
||||
deadParts.add(part);
|
||||
onDetachBlock(part);
|
||||
continue;
|
||||
|
@ -927,7 +926,7 @@ public abstract class MultiblockControllerBase {
|
|||
// coord's part
|
||||
IMultiblockPart part;
|
||||
LinkedList<IMultiblockPart> partsToCheck = new LinkedList<>();
|
||||
IMultiblockPart[] nearbyParts = null;
|
||||
IMultiblockPart[] nearbyParts;
|
||||
int visitedParts = 0;
|
||||
|
||||
partsToCheck.add(referencePart);
|
||||
|
@ -992,7 +991,7 @@ public abstract class MultiblockControllerBase {
|
|||
}
|
||||
|
||||
for (IMultiblockPart part : connectedParts) {
|
||||
if (this.worldObj.isChunkLoaded(part.getWorldLocation())) {
|
||||
if (WorldUtils.isChunkLoaded(worldObj, part.getWorldLocation())) {
|
||||
onDetachBlock(part);
|
||||
}
|
||||
}
|
||||
|
@ -1017,7 +1016,7 @@ public abstract class MultiblockControllerBase {
|
|||
|
||||
for (IMultiblockPart part : connectedParts) {
|
||||
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
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import net.minecraft.util.math.ChunkPos;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import reborncore.RebornCore;
|
||||
import reborncore.common.util.WorldUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
@ -140,7 +141,7 @@ public class MultiblockWorldRegistry {
|
|||
// controller
|
||||
for (IMultiblockPart orphan : orphansToProcess) {
|
||||
coord = orphan.getWorldLocation();
|
||||
if (!this.worldObj.isChunkLoaded(coord)) {
|
||||
if (!WorldUtils.isChunkLoaded(worldObj, coord)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -318,7 +319,7 @@ public class MultiblockWorldRegistry {
|
|||
public void onPartAdded(IMultiblockPart part) {
|
||||
BlockPos pos = part.getWorldLocation();
|
||||
|
||||
if (!this.worldObj.isChunkLoaded(pos)) {
|
||||
if (!WorldUtils.isChunkLoaded(worldObj, pos)) {
|
||||
// Part goes into the waiting-for-chunk-load list
|
||||
Set<IMultiblockPart> partSet;
|
||||
int chunkHash = new ChunkPos(pos).hashCode();
|
||||
|
|
|
@ -46,6 +46,7 @@ import reborncore.common.blockentity.FluidConfiguration;
|
|||
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
||||
import reborncore.common.blockentity.SlotConfiguration;
|
||||
import reborncore.common.chunkloading.ChunkLoaderManager;
|
||||
import reborncore.common.util.WorldUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ import net.minecraft.entity.ItemEntity;
|
|||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkSectionPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
@ -45,10 +46,18 @@ public class WorldUtils {
|
|||
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) {
|
||||
Random rand = new Random();
|
||||
|
||||
|
|
|
@ -498,7 +498,7 @@ public class TRContent {
|
|||
|
||||
public static ItemConvertible[] getCasings() {
|
||||
return Arrays.stream(MachineBlocks.values())
|
||||
.map((Function<MachineBlocks, ItemConvertible>) machineBlocks -> () -> machineBlocks.casing.asItem())
|
||||
.map((Function<MachineBlocks, ItemConvertible>) machineBlocks -> machineBlocks.casing::asItem)
|
||||
.toArray(ItemConvertible[]::new);
|
||||
}
|
||||
}
|
||||
|
@ -855,8 +855,10 @@ public class TRContent {
|
|||
if (blockEntity instanceof PowerAcceptorBlockEntity) {
|
||||
powerAcceptor = (PowerAcceptorBlockEntity) blockEntity;
|
||||
}
|
||||
if (handler != null) {
|
||||
handler.addSpeedMulti(TechRebornConfig.overclockerSpeed);
|
||||
handler.addPowerMulti(TechRebornConfig.overclockerPower);
|
||||
}
|
||||
if (powerAcceptor != null) {
|
||||
powerAcceptor.extraPowerInput += powerAcceptor.getMaxInput(EnergySide.UNKNOWN);
|
||||
powerAcceptor.extraPowerStorage += powerAcceptor.getBaseMaxPower();
|
||||
|
|
Loading…
Reference in a new issue