2016-05-16 22:52:27 +02:00
|
|
|
/*
|
|
|
|
* This file ("TileEntityPhantomRedstoneface.java") is part of the Actually Additions mod for Minecraft.
|
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
|
|
|
* http://ellpeck.de/actaddlicense
|
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
2017-01-01 16:23:26 +01:00
|
|
|
* © 2015-2017 Ellpeck
|
2016-05-16 22:52:27 +02:00
|
|
|
*/
|
|
|
|
|
2016-05-05 17:29:39 +02:00
|
|
|
package de.ellpeck.actuallyadditions.mod.tile;
|
|
|
|
|
|
|
|
import net.minecraft.block.Block;
|
2021-02-27 16:33:00 +01:00
|
|
|
import net.minecraft.block.BlockState;
|
2021-02-27 13:24:45 +01:00
|
|
|
import net.minecraft.util.Direction;
|
2016-12-28 03:12:17 +01:00
|
|
|
import net.minecraftforge.common.capabilities.Capability;
|
2016-05-05 17:29:39 +02:00
|
|
|
|
2021-02-27 16:33:00 +01:00
|
|
|
import java.util.Arrays;
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
public class TileEntityPhantomRedstoneface extends TileEntityPhantomface {
|
2016-05-05 17:29:39 +02:00
|
|
|
|
2021-02-27 13:24:45 +01:00
|
|
|
public final int[] providesStrong = new int[Direction.values().length];
|
|
|
|
public final int[] providesWeak = new int[Direction.values().length];
|
2016-05-05 17:29:39 +02:00
|
|
|
|
2016-05-19 20:05:12 +02:00
|
|
|
private final int[] lastProvidesStrong = new int[this.providesStrong.length];
|
|
|
|
private final int[] lastProvidesWeak = new int[this.providesWeak.length];
|
2016-05-05 17:29:39 +02:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
public TileEntityPhantomRedstoneface() {
|
2021-02-27 16:33:00 +01:00
|
|
|
super(ActuallyTiles.PHANTOMREDSTONEFACE_TILE.get());
|
2016-05-05 17:29:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public void updateEntity() {
|
|
|
|
if (!this.world.isRemote) {
|
|
|
|
if (this.isBoundThingInRange()) {
|
2021-02-26 22:15:48 +01:00
|
|
|
BlockState boundState = this.world.getBlockState(this.boundPosition);
|
2019-05-02 09:10:29 +02:00
|
|
|
if (boundState != null) {
|
2016-05-05 17:29:39 +02:00
|
|
|
Block boundBlock = boundState.getBlock();
|
2019-05-02 09:10:29 +02:00
|
|
|
if (boundBlock != null) {
|
2021-02-27 13:24:45 +01:00
|
|
|
for (int i = 0; i < Direction.values().length; i++) {
|
|
|
|
Direction facing = Direction.values()[i];
|
2017-08-17 07:06:09 +02:00
|
|
|
this.providesWeak[i] = boundState.getWeakPower(this.world, this.boundPosition, facing);
|
|
|
|
this.providesStrong[i] = boundState.getStrongPower(this.world, this.boundPosition, facing);
|
2016-05-05 17:29:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-05 17:50:18 +02:00
|
|
|
}
|
2016-05-05 17:29:39 +02:00
|
|
|
|
2016-05-05 17:50:18 +02:00
|
|
|
super.updateEntity();
|
|
|
|
}
|
2016-05-05 17:29:39 +02:00
|
|
|
|
2016-05-05 17:50:18 +02:00
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
protected boolean doesNeedUpdateSend() {
|
2016-05-05 17:50:18 +02:00
|
|
|
return super.doesNeedUpdateSend() || !Arrays.equals(this.providesStrong, this.lastProvidesStrong) || !Arrays.equals(this.providesWeak, this.lastProvidesWeak);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
protected void onUpdateSent() {
|
2016-05-05 17:50:18 +02:00
|
|
|
System.arraycopy(this.providesWeak, 0, this.lastProvidesWeak, 0, this.providesWeak.length);
|
|
|
|
System.arraycopy(this.providesStrong, 0, this.lastProvidesStrong, 0, this.providesStrong.length);
|
|
|
|
|
|
|
|
super.onUpdateSent();
|
2016-05-05 17:29:39 +02:00
|
|
|
}
|
2016-12-28 03:12:17 +01:00
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
protected boolean isCapabilitySupported(Capability<?> capability) {
|
2016-12-28 03:12:17 +01:00
|
|
|
return false;
|
|
|
|
}
|
2016-05-05 17:29:39 +02:00
|
|
|
}
|