use of mods.railcraft.common.blocks.TileRailcraft in project Railcraft by Railcraft.
the class MultiBlockFormedTrigger method onMultiBlockForm.
@SubscribeEvent
public void onMultiBlockForm(MultiBlockEvent.Form event) {
TileRailcraft tile = event.getMaster();
GameProfile owner = tile.getOwner();
MinecraftServer server = requireNonNull(Game.getServer());
EntityPlayerMP player = server.getPlayerList().getPlayerByUUID(owner.getId());
if (player == null) {
// Offline
return;
}
PlayerAdvancements advancements = player.getAdvancements();
Collection<Listener<Instance>> done = manager.get(advancements).stream().filter(listener -> listener.getCriterionInstance().matches(tile)).collect(Collectors.toList());
for (Listener<Instance> listener : done) {
listener.grantCriterion(advancements);
}
}
use of mods.railcraft.common.blocks.TileRailcraft in project Railcraft by Railcraft.
the class PacketTileRequest method readData.
@Override
public void readData(RailcraftInputStream data) throws IOException {
World world = DimensionManager.getWorld(data.readInt());
if (world == null)
return;
int x = data.readInt();
int y = data.readInt();
int z = data.readInt();
tile = world.getTileEntity(new BlockPos(x, y, z));
if (tile instanceof TileRailcraft && player != null)
PacketBuilder.instance().sendTileEntityPacket(tile, player);
}
use of mods.railcraft.common.blocks.TileRailcraft in project Railcraft by Railcraft.
the class CommandDebug method executeSubCommand.
@Override
public void executeSubCommand(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
if (args.length != 0)
CommandHelpers.throwWrongUsage(sender, this);
RayTraceResult rayTraceResult = MiscTools.rayTracePlayerLook((EntityPlayer) sender);
if (rayTraceResult == null)
CommandHelpers.throwWrongUsage(sender, this);
List<String> debug = Collections.emptyList();
switch(rayTraceResult.typeOfHit) {
case ENTITY:
Entity entity = rayTraceResult.entityHit;
if (entity instanceof EntityMinecart) {
debug = CartTools.getDebugOutput((EntityMinecart) entity);
} else {
throw new EntityInvalidException(entity);
}
break;
case BLOCK:
World world = CommandHelpers.getWorld(sender);
TileEntity tile = WorldPlugin.getBlockTile(world, rayTraceResult.getBlockPos());
if (tile instanceof TileRailcraft) {
debug = ((TileRailcraft) tile).getDebugOutput();
} else {
throw new BlockNotFoundException();
}
break;
}
for (String s : debug) {
printLine(sender, s);
}
}
use of mods.railcraft.common.blocks.TileRailcraft in project Railcraft by Railcraft.
the class StructureLogic method testIfMasterBlock.
protected void testIfMasterBlock() {
// System.out.println("testing structure");
testPatterns();
List<TileRailcraft> old = new ArrayList<>(components);
components.clear();
components.add(tile);
if (patternStates.containsKey(StructurePattern.State.VALID)) {
state = StructureState.VALID;
isMaster = true;
// System.out.println("structure complete");
StructurePattern pattern = patternStates.get(StructurePattern.State.VALID).get(0);
int xWidth = pattern.getPatternWidthX();
int zWidth = pattern.getPatternWidthZ();
int height = pattern.getPatternHeight();
BlockPos offset = getPos().subtract(pattern.getMasterOffset());
Map<BlockPos, StructureLogic> newComponents = new HashMap<>();
for (int px = 0; px < xWidth; px++) {
for (int py = 0; py < height; py++) {
for (int pz = 0; pz < zWidth; pz++) {
char marker = pattern.getPatternMarker(px, py, pz);
if (isMapPositionOtherBlock(marker))
continue;
BlockPos patternPos = new BlockPos(px, py, pz);
BlockPos pos = patternPos.add(offset);
WorldPlugin.getTileEntity(theWorldAsserted(), pos).flatMap(tileToLogic()).ifPresent(l -> {
components.add(l.tile);
newComponents.put(patternPos, l);
});
}
}
}
newComponents.forEach((pos, logic) -> logic.changePattern(pattern, pos));
MinecraftForge.EVENT_BUS.post(new MultiBlockEvent.Form(tile));
} else if (patternStates.containsKey(StructurePattern.State.NOT_LOADED)) {
state = StructureState.UNKNOWN;
} else {
state = StructureState.INVALID;
functionalLogic.getLogic(IDropsInv.class).ifPresent(i -> i.spewInventory(theWorldAsserted(), getPos()));
if (isMaster) {
isMaster = false;
onMasterReset();
sendUpdateToClient();
}
}
old.removeAll(components);
old.stream().filter(t -> !t.isInvalid()).map(tileToLogic()).flatMap(Streams.unwrap()).forEach(t -> t.changePattern(null, null));
}
Aggregations