use of com.simibubi.create.content.contraptions.base.KineticTileEntity in project Create_Aeronautics by Eriksonnaren.
the class TorsionSpringTileEntity method setSource.
public void setSource(BlockPos source) {
super.setSource(source);
TileEntity tileEntity = this.level.getBlockEntity(source);
if (tileEntity instanceof KineticTileEntity) {
KineticTileEntity sourceTe = (KineticTileEntity) tileEntity;
if (this.reActivateSource && Math.abs(sourceTe.getSpeed()) >= Math.abs(this.getGeneratedSpeed())) {
this.reActivateSource = false;
}
}
}
use of com.simibubi.create.content.contraptions.base.KineticTileEntity in project Create by Creators-of-Create.
the class RotationPropagator method handleRemoved.
/**
* Remove the given entity from the network.
*
* @param worldIn
* @param pos
* @param removedTE
*/
public static void handleRemoved(Level worldIn, BlockPos pos, KineticTileEntity removedTE) {
if (worldIn.isClientSide)
return;
if (removedTE == null)
return;
if (removedTE.getTheoreticalSpeed() == 0)
return;
for (BlockPos neighbourPos : getPotentialNeighbourLocations(removedTE)) {
BlockState neighbourState = worldIn.getBlockState(neighbourPos);
if (!(neighbourState.getBlock() instanceof IRotate))
continue;
BlockEntity tileEntity = worldIn.getBlockEntity(neighbourPos);
if (!(tileEntity instanceof KineticTileEntity))
continue;
final KineticTileEntity neighbourTE = (KineticTileEntity) tileEntity;
if (!neighbourTE.hasSource() || !neighbourTE.source.equals(pos))
continue;
propagateMissingSource(neighbourTE);
}
}
use of com.simibubi.create.content.contraptions.base.KineticTileEntity in project Create by Creators-of-Create.
the class RotationPropagator method propagateMissingSource.
/**
* Clear the entire subnetwork depending on the given entity and find a new
* source
*
* @param updateTE
*/
private static void propagateMissingSource(KineticTileEntity updateTE) {
final Level world = updateTE.getLevel();
List<KineticTileEntity> potentialNewSources = new LinkedList<>();
List<BlockPos> frontier = new LinkedList<>();
frontier.add(updateTE.getBlockPos());
BlockPos missingSource = updateTE.hasSource() ? updateTE.source : null;
while (!frontier.isEmpty()) {
final BlockPos pos = frontier.remove(0);
BlockEntity tileEntity = world.getBlockEntity(pos);
if (!(tileEntity instanceof KineticTileEntity))
continue;
final KineticTileEntity currentTE = (KineticTileEntity) tileEntity;
currentTE.removeSource();
currentTE.sendData();
for (KineticTileEntity neighbourTE : getConnectedNeighbours(currentTE)) {
if (neighbourTE.getBlockPos().equals(missingSource))
continue;
if (!neighbourTE.hasSource())
continue;
if (!neighbourTE.source.equals(pos)) {
potentialNewSources.add(neighbourTE);
continue;
}
if (neighbourTE.isSource())
potentialNewSources.add(neighbourTE);
frontier.add(neighbourTE.getBlockPos());
}
}
for (KineticTileEntity newSource : potentialNewSources) {
if (newSource.hasSource() || newSource.isSource()) {
propagateNewSource(newSource);
return;
}
}
}
use of com.simibubi.create.content.contraptions.base.KineticTileEntity in project Create by Creators-of-Create.
the class RotationPropagator method getConnectedNeighbours.
private static List<KineticTileEntity> getConnectedNeighbours(KineticTileEntity te) {
List<KineticTileEntity> neighbours = new LinkedList<>();
for (BlockPos neighbourPos : getPotentialNeighbourLocations(te)) {
final KineticTileEntity neighbourTE = findConnectedNeighbour(te, neighbourPos);
if (neighbourTE == null)
continue;
neighbours.add(neighbourTE);
}
return neighbours;
}
use of com.simibubi.create.content.contraptions.base.KineticTileEntity in project Create by Creators-of-Create.
the class KineticDebugger method tick.
public static void tick() {
if (!isActive()) {
if (KineticTileEntityRenderer.rainbowMode) {
KineticTileEntityRenderer.rainbowMode = false;
CreateClient.BUFFER_CACHE.invalidate();
}
return;
}
KineticTileEntity te = getSelectedTE();
if (te == null)
return;
Level world = Minecraft.getInstance().level;
BlockPos toOutline = te.hasSource() ? te.source : te.getBlockPos();
BlockState state = te.getBlockState();
VoxelShape shape = world.getBlockState(toOutline).getBlockSupportShape(world, toOutline);
if (te.getTheoreticalSpeed() != 0 && !shape.isEmpty())
CreateClient.OUTLINER.chaseAABB("kineticSource", shape.bounds().move(toOutline)).lineWidth(1 / 16f).colored(te.hasSource() ? Color.generateFromLong(te.network).getRGB() : 0xffcc00);
if (state.getBlock() instanceof IRotate) {
Axis axis = ((IRotate) state.getBlock()).getRotationAxis(state);
Vec3 vec = Vec3.atLowerCornerOf(Direction.get(AxisDirection.POSITIVE, axis).getNormal());
Vec3 center = VecHelper.getCenterOf(te.getBlockPos());
CreateClient.OUTLINER.showLine("rotationAxis", center.add(vec), center.subtract(vec)).lineWidth(1 / 16f);
}
}
Aggregations