use of mcjty.rftools.dimension.RfToolsDimensionManager in project RFTools by McJty.
the class CmdDelEffect method execute.
@Override
public void execute(ICommandSender sender, String[] args) {
if (args.length < 2) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Several parameters are missing!"));
return;
} else if (args.length > 2) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
return;
}
String effectName = fetchString(sender, args, 1, "");
effectName = "EFFECT_" + effectName.toUpperCase();
EffectType type = null;
try {
type = EffectType.valueOf(effectName);
} catch (IllegalArgumentException e) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Bad effect name!"));
return;
}
World world = sender.getEntityWorld();
int dim = world.provider.dimensionId;
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
DimensionInformation information = dimensionManager.getDimensionInformation(dim);
if (information == null) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Not an RFTools dimension!"));
return;
}
if (!information.getEffectTypes().contains(type)) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "This effect is not active!"));
return;
}
information.getEffectTypes().remove(type);
dimensionManager.save(world);
}
use of mcjty.rftools.dimension.RfToolsDimensionManager in project RFTools by McJty.
the class CmdLoadDim method execute.
@Override
public void execute(ICommandSender sender, String[] args) {
if (args.length < 3) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "The dimension and filename parameters are missing!"));
return;
} else if (args.length > 3) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
return;
}
int dim = fetchInt(sender, args, 1, 0);
String filename = fetchString(sender, args, 2, null);
World world = sender.getEntityWorld();
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
if (dimensionManager.getDimensionDescriptor(dim) == null) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Not an RFTools dimension!"));
return;
}
DimensionInformation information = dimensionManager.getDimensionInformation(dim);
String error = information.loadFromJson(filename);
if (error != null) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Error: " + error));
} else {
dimensionManager.save(world);
}
}
use of mcjty.rftools.dimension.RfToolsDimensionManager in project RFTools by McJty.
the class FMLEventHandlers method onConnectionCreated.
@SubscribeEvent
public void onConnectionCreated(FMLNetworkEvent.ServerConnectionFromClientEvent event) {
Logging.log("SMP: Sync dimensions to client");
DimensionSyncPacket packet = new DimensionSyncPacket();
EntityPlayer player = ((NetHandlerPlayServer) event.handler).playerEntity;
RfToolsDimensionManager manager = RfToolsDimensionManager.getDimensionManager(player.getEntityWorld());
for (Integer id : manager.getDimensions().keySet()) {
Logging.log("Sending over dimension " + id + " to the client");
packet.addDimension(id);
}
RFTools.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.DISPATCHER);
RFTools.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(event.manager.channel().attr(NetworkDispatcher.FML_DISPATCHER).get());
RFTools.channels.get(Side.SERVER).writeOutbound(packet);
}
use of mcjty.rftools.dimension.RfToolsDimensionManager in project RFTools by McJty.
the class ForgeEventHandlers method onEntityJoinWorldEvent.
@SubscribeEvent
public void onEntityJoinWorldEvent(EntityJoinWorldEvent event) {
World world = event.world;
if (world.isRemote) {
return;
}
int id = world.provider.dimensionId;
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
DimensionInformation dimensionInformation = dimensionManager.getDimensionInformation(id);
if (dimensionInformation != null && dimensionInformation.isNoanimals()) {
if (event.entity instanceof IAnimals && !(event.entity instanceof IMob)) {
event.setCanceled(true);
Logging.logDebug("Noanimals dimension: Prevented a spawn of " + event.entity.getClass().getName());
}
}
}
use of mcjty.rftools.dimension.RfToolsDimensionManager in project RFTools by McJty.
the class ForgeOregenHandlers method onGenerateMinable.
@SubscribeEvent
public void onGenerateMinable(OreGenEvent.GenerateMinable event) {
World world = event.world;
int id = world.provider.dimensionId;
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
DimensionInformation information = dimensionManager.getDimensionInformation(id);
if (information != null && information.hasFeatureType(FeatureType.FEATURE_CLEAN)) {
event.setResult(Event.Result.DENY);
}
}
Aggregations