Port more stuff
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.debug;
|
||||
|
||||
import net.minecraft.block.Material;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
|
||||
public class ChunkLoaderBlock extends AEBaseTileBlock<ChunkLoaderBlockEntity> {
|
||||
|
||||
public ChunkLoaderBlock() {
|
||||
super(defaultProps(Material.METAL));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.debug;
|
||||
|
||||
import net.minecraft.util.Tickable;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
|
||||
import appeng.core.AELog;
|
||||
import appeng.tile.AEBaseBlockEntity;
|
||||
|
||||
public class ChunkLoaderBlockEntity extends AEBaseBlockEntity implements Tickable {
|
||||
|
||||
public ChunkLoaderBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReady() {
|
||||
if (world.isClient) {
|
||||
return;
|
||||
}
|
||||
|
||||
World world = getWorld();
|
||||
if (world instanceof ServerWorld) {
|
||||
ChunkPos chunkPos = new ChunkPos(getPos());
|
||||
((ServerWorld) world).setChunkForced(chunkPos.x, chunkPos.z, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markRemoved() {
|
||||
super.markRemoved();
|
||||
World world = getWorld();
|
||||
if (world instanceof ServerWorld) {
|
||||
ChunkPos chunkPos = new ChunkPos(getPos());
|
||||
((ServerWorld) world).setChunkForced(chunkPos.x, chunkPos.z, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
// Validate the force-status
|
||||
World world = getWorld();
|
||||
if (world instanceof ServerWorld) {
|
||||
ChunkPos chunkPos = new ChunkPos(getPos());
|
||||
ServerWorld serverWorld = (ServerWorld) world;
|
||||
|
||||
if (!serverWorld.getForcedChunks().contains(chunkPos.toLong())) {
|
||||
AELog.debug("Force-loading chunk @ %d,%d in world %s", chunkPos.x, chunkPos.z,
|
||||
serverWorld.getRegistryKey().getValue());
|
||||
serverWorld.setChunkForced(chunkPos.x, chunkPos.z, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.debug;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
|
||||
public class CubeGeneratorBlock extends AEBaseTileBlock<CubeGeneratorBlockEntity> {
|
||||
|
||||
public CubeGeneratorBlock() {
|
||||
super(defaultProps(Material.METAL));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
|
||||
final CubeGeneratorBlockEntity tcg = this.getBlockEntity(w, pos);
|
||||
if (tcg != null) {
|
||||
tcg.click(player);
|
||||
}
|
||||
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.debug;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.AutomaticItemPlacementContext;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
import net.minecraft.util.Tickable;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.text.LiteralText;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import appeng.tile.AEBaseBlockEntity;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class CubeGeneratorBlockEntity extends AEBaseBlockEntity implements Tickable {
|
||||
|
||||
private int size = 3;
|
||||
private ItemStack is = ItemStack.EMPTY;
|
||||
private int countdown = 20 * 10;
|
||||
|
||||
public CubeGeneratorBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
if (!this.is.isEmpty() && Platform.isServer()) {
|
||||
this.countdown--;
|
||||
|
||||
if (this.countdown % 20 == 0) {
|
||||
AppEng.instance().getPlayers().forEach(e -> {
|
||||
e.sendSystemMessage(new LiteralText("Spawning in... " + (this.countdown / 20)), Util.NIL_UUID);
|
||||
});
|
||||
}
|
||||
|
||||
if (this.countdown <= 0) {
|
||||
this.spawn();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void spawn() {
|
||||
this.world.removeBlock(this.pos, false);
|
||||
|
||||
final Item i = this.is.getItem();
|
||||
final Direction side = Direction.UP;
|
||||
|
||||
final int half = (int) Math.floor(this.size / 2);
|
||||
|
||||
for (int y = 0; y < this.size; y++) {
|
||||
for (int x = -half; x < half; x++) {
|
||||
for (int z = -half; z < half; z++) {
|
||||
final BlockPos p = this.pos.add(x, y - 1, z);
|
||||
ItemUsageContext useContext = new AutomaticItemPlacementContext(this.world, p, side, this.is,
|
||||
side.getOpposite());
|
||||
i.useOnBlock(useContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void click(final PlayerEntity player) {
|
||||
if (Platform.isServer()) {
|
||||
final ItemStack hand = player.inventory.getMainHandStack();
|
||||
|
||||
if (hand.isEmpty()) {
|
||||
this.is = ItemStack.EMPTY;
|
||||
|
||||
if (player.isInSneakingPose()) {
|
||||
this.size--;
|
||||
} else {
|
||||
this.size++;
|
||||
}
|
||||
|
||||
if (this.size < 3) {
|
||||
this.size = 3;
|
||||
}
|
||||
if (this.size > 64) {
|
||||
this.size = 64;
|
||||
}
|
||||
|
||||
player.sendSystemMessage(new LiteralText("Size: " + this.size), Util.NIL_UUID);
|
||||
} else {
|
||||
this.countdown = 20 * 10;
|
||||
this.is = hand;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.debug;
|
||||
|
||||
import net.minecraft.block.Material;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
|
||||
public class ItemGenBlock extends AEBaseTileBlock<ItemGenBlockEntity> {
|
||||
|
||||
public ItemGenBlock() {
|
||||
super(defaultProps(Material.METAL));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.debug;
|
||||
|
||||
import alexiil.mc.lib.attributes.AttributeList;
|
||||
import alexiil.mc.lib.attributes.Simulation;
|
||||
import alexiil.mc.lib.attributes.item.ItemExtractable;
|
||||
import alexiil.mc.lib.attributes.item.filter.ExactItemStackFilter;
|
||||
import alexiil.mc.lib.attributes.item.filter.ItemFilter;
|
||||
import appeng.tile.AEBaseBlockEntity;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Queue;
|
||||
|
||||
public class ItemGenBlockEntity extends AEBaseBlockEntity {
|
||||
|
||||
private static final Queue<ItemStack> POSSIBLE_ITEMS = new ArrayDeque<>();
|
||||
|
||||
private final ItemExtractable handler = new QueuedItemHandler();
|
||||
|
||||
public ItemGenBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
if (POSSIBLE_ITEMS.isEmpty()) {
|
||||
for (final Item mi : Registry.ITEM) {
|
||||
if (mi != null && mi != Items.AIR) {
|
||||
if (mi.isDamageable()) {
|
||||
ItemStack sampleStack = new ItemStack(mi);
|
||||
int maxDamage = sampleStack.getMaxDamage();
|
||||
for (int dmg = 0; dmg < maxDamage; dmg++) {
|
||||
ItemStack is = sampleStack.copy();
|
||||
is.setDamage(dmg);
|
||||
POSSIBLE_ITEMS.add(is);
|
||||
}
|
||||
} else {
|
||||
if (mi.getGroup() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final DefaultedList<ItemStack> list = DefaultedList.of();
|
||||
mi.appendStacks(mi.getGroup(), list);
|
||||
POSSIBLE_ITEMS.addAll(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAllAttributes(World world, BlockPos pos, BlockState state, AttributeList<?> to) {
|
||||
to.offer(handler);
|
||||
}
|
||||
|
||||
class QueuedItemHandler implements ItemExtractable {
|
||||
|
||||
@Override
|
||||
public ItemStack attemptExtraction(ItemFilter itemFilter, int maxAmount, Simulation simulation) {
|
||||
// When item filter asks for a specific item, just return that
|
||||
if (itemFilter instanceof ExactItemStackFilter) {
|
||||
return ((ExactItemStackFilter) itemFilter).stack.copy();
|
||||
}
|
||||
|
||||
final ItemStack is = POSSIBLE_ITEMS.peek();
|
||||
|
||||
if (is == null || !itemFilter.matches(is)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
return simulation == Simulation.SIMULATE ? is.copy() : this.getNextItem();
|
||||
}
|
||||
|
||||
private ItemStack getNextItem() {
|
||||
final ItemStack is = POSSIBLE_ITEMS.poll();
|
||||
|
||||
POSSIBLE_ITEMS.add(is);
|
||||
return is.copy();
|
||||
}
|
||||
}
|
||||
|
||||
;
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.debug;
|
||||
|
||||
import appeng.hooks.AEToolItem;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.packet.s2c.play.ChunkDataS2CPacket;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.math.BlockBox;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
import appeng.worldgen.meteorite.CraterType;
|
||||
import appeng.worldgen.meteorite.MeteoritePlacer;
|
||||
import appeng.worldgen.meteorite.PlacedMeteoriteSettings;
|
||||
import appeng.worldgen.meteorite.debug.MeteoriteSpawner;
|
||||
import net.minecraft.world.chunk.WorldChunk;
|
||||
|
||||
public class MeteoritePlacerItem extends AEBaseItem implements AEToolItem {
|
||||
|
||||
private static final String MODE_TAG = "mode";
|
||||
|
||||
public MeteoritePlacerItem(Settings properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
|
||||
if (world.isClient()) {
|
||||
return TypedActionResult.pass(player.getStackInHand(hand));
|
||||
}
|
||||
|
||||
if (player.isSneaking()) {
|
||||
final ItemStack itemStack = player.getStackInHand(hand);
|
||||
final CompoundTag tag = itemStack.getOrCreateTag();
|
||||
|
||||
if (tag.contains(MODE_TAG)) {
|
||||
final byte mode = tag.getByte("mode");
|
||||
tag.putByte(MODE_TAG, (byte) ((mode + 1) % CraterType.values().length));
|
||||
} else {
|
||||
tag.putByte(MODE_TAG, (byte) CraterType.NORMAL.ordinal());
|
||||
}
|
||||
|
||||
CraterType craterType = CraterType.values()[tag.getByte(MODE_TAG)];
|
||||
|
||||
player.sendSystemMessage(new LiteralText(craterType.name()), Util.NIL_UUID);
|
||||
|
||||
return TypedActionResult.success(itemStack);
|
||||
}
|
||||
|
||||
return super.use(world, player, hand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onItemUseFirst(ItemStack stack, ItemUsageContext context) {
|
||||
if (context.getWorld().isClient()) {
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
ServerPlayerEntity player = (ServerPlayerEntity) context.getPlayer();
|
||||
ServerWorld world = (ServerWorld) context.getWorld();
|
||||
BlockPos pos = context.getBlockPos();
|
||||
|
||||
if (player == null) {
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
CompoundTag tag = stack.getOrCreateTag();
|
||||
if (!tag.contains(MODE_TAG)) {
|
||||
tag.putByte(MODE_TAG, (byte) CraterType.NORMAL.ordinal());
|
||||
}
|
||||
|
||||
// See MeteoriteStructure for original code
|
||||
float coreRadius = (Platform.getRandomFloat() * 6.0f) + 2;
|
||||
boolean pureCrater = Platform.getRandomFloat() > 0.5f;
|
||||
CraterType craterType = CraterType.values()[tag.getByte(MODE_TAG)];
|
||||
|
||||
MeteoriteSpawner spawner = new MeteoriteSpawner();
|
||||
PlacedMeteoriteSettings spawned = spawner.trySpawnMeteoriteAtSuitableHeight(world, pos, coreRadius, craterType,
|
||||
pureCrater, false);
|
||||
|
||||
if (spawned == null) {
|
||||
player.sendMessage(new LiteralText("Un-suitable Location."), false);
|
||||
return ActionResult.FAIL;
|
||||
}
|
||||
|
||||
// Since we don't know yet if the meteorite will be underground or not,
|
||||
// we have to assume maximum size
|
||||
int range = (int) Math.ceil((coreRadius * 2 + 5) * 5f);
|
||||
|
||||
BlockBox boundingBox = new BlockBox(pos.getX() - range, pos.getY(), pos.getZ() - range,
|
||||
pos.getX() + range, pos.getY(), pos.getZ() + range);
|
||||
|
||||
final MeteoritePlacer placer = new MeteoritePlacer(world, spawned, boundingBox);
|
||||
placer.place();
|
||||
|
||||
player.sendMessage(new LiteralText("Spawned at y=" + spawned.getPos().getY() + " range=" + range
|
||||
+ " biomeCategory=" + world.getBiome(pos).getCategory()), false);
|
||||
|
||||
// The placer will not send chunks to the player since it's used as part
|
||||
// of world-gen normally, so we'll have to do it ourselves. Since this
|
||||
// is a debug tool, we'll not care about being terribly efficient here
|
||||
ChunkPos.stream(new ChunkPos(spawned.getPos()), 2).forEach(cp -> {
|
||||
WorldChunk c = world.getChunk(cp.x, cp.z);
|
||||
player.networkHandler.sendPacket(new ChunkDataS2CPacket(c, 65535, false)); // 65535 == full chunk
|
||||
});
|
||||
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.debug;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
|
||||
public class PhantomNodeBlock extends AEBaseTileBlock<PhantomNodeBlockEntity> {
|
||||
|
||||
public PhantomNodeBlock() {
|
||||
super(defaultProps(Material.METAL));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockHitResult hit) {
|
||||
final PhantomNodeBlockEntity tpn = this.getBlockEntity(w, pos);
|
||||
tpn.triggerCrashMode();
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.debug;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.util.math.Direction;
|
||||
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.tile.grid.AENetworkBlockEntity;
|
||||
|
||||
public class PhantomNodeBlockEntity extends AENetworkBlockEntity {
|
||||
|
||||
private AENetworkProxy proxy = null;
|
||||
private boolean crashMode = false;
|
||||
|
||||
public PhantomNodeBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getGridNode(final AEPartLocation dir) {
|
||||
if (!this.crashMode) {
|
||||
return super.getGridNode(dir);
|
||||
}
|
||||
|
||||
return this.proxy.getNode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReady() {
|
||||
super.onReady();
|
||||
this.proxy = this.createProxy();
|
||||
this.proxy.onReady();
|
||||
this.crashMode = true;
|
||||
}
|
||||
|
||||
void triggerCrashMode() {
|
||||
if (this.proxy != null) {
|
||||
this.crashMode = true;
|
||||
this.proxy.setValidSides(EnumSet.allOf(Direction.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user