use of net.minecraft.block.entity.BlockEntity in project FastAsyncWorldEdit by IntellectualSites.
the class FabricWorldNativeAccess method updateTileEntity.
@Override
public boolean updateTileEntity(BlockPos position, com.sk89q.jnbt.CompoundTag tag) {
CompoundTag nativeTag = NBTConverter.toNative(tag);
BlockEntity tileEntity = getWorld().getWorldChunk(position).getBlockEntity(position);
if (tileEntity == null) {
return false;
}
tileEntity.setLocation(getWorld(), position);
tileEntity.fromTag(nativeTag);
return true;
}
use of net.minecraft.block.entity.BlockEntity in project SeedcrackerX by 19MisterX98.
the class DungeonFinder method findInChunk.
@Override
public List<BlockPos> findInChunk() {
// Gets all the positions with a mob spawner in the chunk.
List<BlockPos> result = super.findInChunk();
if (result.size() != 1)
return new ArrayList<>();
result.removeIf(pos -> {
BlockEntity blockEntity = this.world.getBlockEntity(pos);
if (!(blockEntity instanceof MobSpawnerBlockEntity))
return true;
int count = 0;
for (BlockPos blockPos : POSSIBLE_FLOOR_POSITIONS) {
BlockPos currentPos = pos.add(blockPos);
Block currentBlock = this.world.getBlockState(currentPos).getBlock();
if (currentBlock == Blocks.COBBLESTONE || currentBlock == Blocks.MOSSY_COBBLESTONE) {
count++;
}
}
return count < 20;
});
if (result.size() != 1)
return new ArrayList<>();
Biome biome = this.world.getBiomeForNoiseGen((this.chunkPos.x << 2) + 2, 0, (this.chunkPos.z << 2) + 2).value();
BlockPos pos = result.get(0);
if (Config.get().getVersion().isNewerThan(MCVersion.v1_17_1)) {
Decorator.Data<?> data;
if (pos.getY() < 0) {
data = Features.DEEP_DUNGEON.at(pos.getX(), pos.getY(), pos.getZ(), BiomeFixer.swap(biome));
} else {
data = Features.DUNGEON.at(pos.getX(), pos.getY(), pos.getZ(), null, null, BiomeFixer.swap(biome), null);
}
this.renderers.add(new Cube(pos, new Color(255, 0, 0)));
SeedCracker.get().getDataStorage().addBaseData(data, DataAddedEvent.POKE_BIOMES);
return result;
}
Vec3i size = this.getDungeonSize(pos);
int[] floorCalls = this.getFloorCalls(size, pos);
Dungeon.Data data = Features.DUNGEON.at(pos.getX(), pos.getY(), pos.getZ(), size, floorCalls, BiomeFixer.swap(biome), heightContext);
if (AntiXRay(pos) && Config.get().antiXrayBypass) {
if (SeedCracker.get().getDataStorage().baseSeedData.contains(new DataStorage.Entry<>(data, null))) {
return result;
}
this.renderers.add(new Cube(pos, new Color(255, 0, 0)));
Thread floorCallsUpdater = new Thread(() -> {
try {
// server needs to send the blocks before we do a second check
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
int[] floorCallsAfter = this.getFloorCalls(size, pos);
for (int i = 0; i < floorCallsAfter.length; i++) {
if (floorCallsAfter[i] != 2) {
floorCalls[i] = floorCallsAfter[i];
}
}
if (SeedCracker.get().getDataStorage().addBaseData(data, data::onDataAdded)) {
if (data.usesFloor()) {
this.renderers.add(new Cuboid(pos.subtract(size), pos.add(size).add(1, -1, 1), new Color(255, 0, 0)));
}
} else {
this.renderers.clear();
}
});
blockUpdateExploit(pos, size, floorCallsUpdater);
} else if (SeedCracker.get().getDataStorage().addBaseData(data, data::onDataAdded)) {
this.renderers.add(new Cube(pos, new Color(255, 0, 0)));
if (data.usesFloor()) {
this.renderers.add(new Cuboid(pos.subtract(size), pos.add(size).add(1, -1, 1), new Color(255, 0, 0)));
}
}
return result;
}
use of net.minecraft.block.entity.BlockEntity in project SeedcrackerX by 19MisterX98.
the class ShipwreckFinder method findInChunk.
@Override
public List<BlockPos> findInChunk() {
Biome biome = this.world.getBiomeForNoiseGen((this.chunkPos.x << 2) + 2, 64, (this.chunkPos.z << 2) + 2).value();
if (!Features.SHIPWRECK.isValidBiome(BiomeFixer.swap(biome))) {
return new ArrayList<>();
}
List<BlockPos> result = super.findInChunk();
result.removeIf(pos -> {
BlockState state = this.world.getBlockState(pos);
if (state.get(ChestBlock.CHEST_TYPE) != ChestType.SINGLE)
return true;
BlockEntity blockEntity = this.world.getBlockEntity(pos);
if (!(blockEntity instanceof ChestBlockEntity))
return true;
return !this.onChestFound(pos);
});
return result;
}
use of net.minecraft.block.entity.BlockEntity in project tweakermore by Fallen-Breath.
the class PlacementTweaksMixin method doSchematicWorldPickBlock.
/**
* Stolen from {@link fi.dy.masa.litematica.util.WorldUtils#doSchematicWorldPickBlock}
*/
private static void doSchematicWorldPickBlock(MinecraftClient mc, BlockPos pos, Hand hand) {
World schematicWorld = SchematicWorldHandler.getSchematicWorld();
World clientWorld = mc.world;
if (schematicWorld != null && mc.player != null && clientWorld != null && mc.interactionManager != null) {
LayerRange layerRange = DataManager.getRenderLayerRange();
if (!layerRange.isPositionWithinRange(pos)) {
return;
}
BlockState state = schematicWorld.getBlockState(pos);
ItemStack stack = MaterialCache.getInstance().getRequiredBuildItemForState(state, schematicWorld, pos);
// System.err.println(pos + " " + state + " " + stack);
if (!stack.isEmpty()) {
PlayerInventory inv = mc.player.inventory;
stack = stack.copy();
if (mc.player.abilities.creativeMode) {
BlockEntity te = schematicWorld.getBlockEntity(pos);
if (GuiBase.isCtrlDown() && te != null && clientWorld.isAir(pos)) {
ItemUtils.storeTEInStack(stack, te);
}
InventoryUtils.setPickedItemToHand(stack, mc);
mc.interactionManager.clickCreativeStack(mc.player.getStackInHand(Hand.MAIN_HAND), 36 + inv.selectedSlot);
} else {
int slot = inv.getSlotWithStack(stack);
boolean shouldPick = inv.selectedSlot != slot;
boolean canPick = slot != -1;
if (shouldPick && canPick) {
InventoryUtils.setPickedItemToHand(stack, mc);
}
}
// so hand restore works fine
PlacementTweaks.cacheStackInHand(hand);
}
}
}
use of net.minecraft.block.entity.BlockEntity in project KahzerxMod by otakucraft.
the class WorldBlockEntityMixin method onTick.
@Redirect(method = "tickBlockEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/BlockEntityTickInvoker;tick()V"))
private void onTick(BlockEntityTickInvoker instance) {
instance.tick();
BlockEntity be = getBlockEntity(instance.getPos());
if (be == null) {
return;
}
BlockEntitiesProfiler.addBlockEntity(be, (World) (Object) this);
}
Aggregations