use of com.simibubi.create.foundation.tileEntity.SmartTileEntity in project Create_Aeronautics by Eriksonnaren.
the class AirshipContraptionEntity method handle.
public void handle(AirshipContraptionBlockUpdateInfo info) {
fakeClientWorld.setBlock(info.pos, info.state, 1);
if (info.tileEntityNBT != null) {
TileEntity existingBE = fakeClientWorld.getBlockEntity(info.pos);
if (existingBE != null) {
// existingBE.setLevelAndPosition(fakeClientWorld, info.pos);
// if(existingBE instanceof SmartTileEntity) {
// ((SmartTileEntity) existingBE).readClientUpdate(info.state, info.tileEntityNBT);
// } else {
// existingBE.getUpdatePacket().handleUpdateTag(info.state, info.tileEntityNBT);
// }
// fakeClientWorld.setBlockEntity(info.pos, existingBE);
addTileData(existingBE, info.pos.offset(0, -getPlotPos().getY(), 0), info.state);
} else {
TileEntityType<?> type = ForgeRegistries.TILE_ENTITIES.getValue(new ResourceLocation(info.tileEntityNBT.getString("id")));
if (type == null)
return;
TileEntity te = type.create();
if (te == null)
return;
te.setLevelAndPosition(fakeClientWorld, info.pos);
te.handleUpdateTag(info.state, info.tileEntityNBT);
te.load(info.state, info.tileEntityNBT);
fakeClientWorld.setBlockEntity(info.pos, te);
addTileData(te, info.pos.offset(0, -getPlotPos().getY(), 0), info.state);
}
}
}
use of com.simibubi.create.foundation.tileEntity.SmartTileEntity in project Create by Creators-of-Create.
the class PonderWorld method onTEadded.
@Override
protected void onTEadded(BlockEntity tileEntity, BlockPos pos) {
super.onTEadded(tileEntity, pos);
if (!(tileEntity instanceof SmartTileEntity))
return;
SmartTileEntity smartTileEntity = (SmartTileEntity) tileEntity;
smartTileEntity.markVirtual();
}
use of com.simibubi.create.foundation.tileEntity.SmartTileEntity in project Create by Creators-of-Create.
the class ScrollValueHandler method onScroll.
@OnlyIn(Dist.CLIENT)
public static boolean onScroll(double delta) {
Minecraft mc = Minecraft.getInstance();
HitResult objectMouseOver = mc.hitResult;
if (!(objectMouseOver instanceof BlockHitResult))
return false;
BlockHitResult result = (BlockHitResult) objectMouseOver;
ClientLevel world = mc.level;
BlockPos blockPos = result.getBlockPos();
ScrollValueBehaviour scrolling = TileEntityBehaviour.get(world, blockPos, ScrollValueBehaviour.TYPE);
if (scrolling == null)
return false;
if (!scrolling.isActive())
return false;
if (!mc.player.mayBuild())
return false;
if (scrolling.needsWrench && !AllItems.WRENCH.isIn(mc.player.getMainHandItem()))
return false;
passiveScrollDirection = (float) -delta;
wrenchCog.bump(3, -delta * 10);
int prev = scrolling.scrollableValue;
if (scrolling.slotPositioning instanceof Sided)
((Sided) scrolling.slotPositioning).fromSide(result.getDirection());
if (!scrolling.testHit(objectMouseOver.getLocation()))
return false;
if (scrolling instanceof BulkScrollValueBehaviour && AllKeys.ctrlDown()) {
BulkScrollValueBehaviour bulkScrolling = (BulkScrollValueBehaviour) scrolling;
for (SmartTileEntity te : bulkScrolling.getBulk()) {
ScrollValueBehaviour other = te.getBehaviour(ScrollValueBehaviour.TYPE);
if (other != null)
applyTo(delta, other);
}
} else
applyTo(delta, scrolling);
if (prev != scrolling.scrollableValue) {
float pitch = (scrolling.scrollableValue - scrolling.min) / (float) (scrolling.max - scrolling.min);
pitch = Mth.lerp(pitch, 1.5f, 2f);
AllSoundEvents.SCROLL_VALUE.play(world, mc.player, blockPos, 1, pitch);
}
return true;
}
use of com.simibubi.create.foundation.tileEntity.SmartTileEntity in project Create by Creators-of-Create.
the class FilteringRenderer method renderOnTileEntity.
public static void renderOnTileEntity(SmartTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
if (te == null || te.isRemoved())
return;
Entity cameraEntity = Minecraft.getInstance().cameraEntity;
float max = AllConfigs.CLIENT.filterItemRenderDistance.getF();
if (!te.isVirtual() && cameraEntity != null && cameraEntity.position().distanceToSqr(VecHelper.getCenterOf(te.getBlockPos())) > (max * max))
return;
FilteringBehaviour behaviour = te.getBehaviour(FilteringBehaviour.TYPE);
if (behaviour == null)
return;
if (!behaviour.isActive())
return;
if (behaviour.getFilter().isEmpty() && !(behaviour instanceof SidedFilteringBehaviour))
return;
ValueBoxTransform slotPositioning = behaviour.slotPositioning;
BlockState blockState = te.getBlockState();
if (slotPositioning instanceof ValueBoxTransform.Sided) {
ValueBoxTransform.Sided sided = (ValueBoxTransform.Sided) slotPositioning;
Direction side = sided.getSide();
for (Direction d : Iterate.directions) {
ItemStack filter = behaviour.getFilter(d);
if (filter.isEmpty())
continue;
sided.fromSide(d);
if (!slotPositioning.shouldRender(blockState))
continue;
ms.pushPose();
slotPositioning.transform(blockState, ms);
ValueBoxRenderer.renderItemIntoValueBox(filter, ms, buffer, light, overlay);
ms.popPose();
}
sided.fromSide(side);
return;
} else if (slotPositioning.shouldRender(blockState)) {
ms.pushPose();
slotPositioning.transform(blockState, ms);
ValueBoxRenderer.renderItemIntoValueBox(behaviour.getFilter(), ms, buffer, light, overlay);
ms.popPose();
}
}
use of com.simibubi.create.foundation.tileEntity.SmartTileEntity in project Create by Creators-of-Create.
the class LinkRenderer method renderOnTileEntity.
public static void renderOnTileEntity(SmartTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
if (te == null || te.isRemoved())
return;
Entity cameraEntity = Minecraft.getInstance().cameraEntity;
float max = AllConfigs.CLIENT.filterItemRenderDistance.getF();
if (!te.isVirtual() && cameraEntity != null && cameraEntity.position().distanceToSqr(VecHelper.getCenterOf(te.getBlockPos())) > (max * max))
return;
LinkBehaviour behaviour = te.getBehaviour(LinkBehaviour.TYPE);
if (behaviour == null)
return;
for (boolean first : Iterate.trueAndFalse) {
ValueBoxTransform transform = first ? behaviour.firstSlot : behaviour.secondSlot;
ItemStack stack = first ? behaviour.frequencyFirst.getStack() : behaviour.frequencyLast.getStack();
ms.pushPose();
transform.transform(te.getBlockState(), ms);
ValueBoxRenderer.renderItemIntoValueBox(stack, ms, buffer, light, overlay);
ms.popPose();
}
}
Aggregations