use of com.enderio.core.common.util.DyeColor in project EnderIO by SleepyTrousers.
the class ItemSoulVial method addInformation.
@Override
@SideOnly(Side.CLIENT)
public void addInformation(@Nonnull ItemStack stack, @Nullable World worldIn, @Nonnull List<String> tooltip, @Nonnull ITooltipFlag flagIn) {
super.addInformation(stack, worldIn, tooltip, flagIn);
CapturedMob capturedMob = CapturedMob.create(stack);
if (capturedMob != null) {
tooltip.add(capturedMob.getDisplayName());
float health = capturedMob.getHealth();
if (health >= 0) {
float maxHealth = capturedMob.getMaxHealth();
if (maxHealth >= 0) {
tooltip.add(Lang.SOUL_VIAL_HEALTH.get(String.format("%3.1f/%3.1f", health, maxHealth)));
} else {
tooltip.add(Lang.SOUL_VIAL_HEALTH.get(String.format("%3.1f", health)));
}
}
String fluidName = capturedMob.getFluidName();
if (fluidName != null) {
Fluid fluid = FluidRegistry.getFluid(fluidName);
if (fluid != null) {
String localizedName = fluid.getLocalizedName(new FluidStack(fluid, 1));
tooltip.add(Lang.SOUL_VIAL_FLUID.get(localizedName));
}
}
DyeColor color = capturedMob.getColor();
if (color != null) {
tooltip.add(Lang.SOUL_VIAL_COLOR.get(color.getLocalisedName()));
}
} else {
tooltip.add(Lang.SOUL_VIAL_EMPTY.get());
}
}
use of com.enderio.core.common.util.DyeColor in project EnderIO by SleepyTrousers.
the class PowerConduit method onBlockActivated.
@Override
public boolean onBlockActivated(@Nonnull EntityPlayer player, @Nonnull EnumHand hand, @Nonnull RaytraceResult res, @Nonnull List<RaytraceResult> all) {
DyeColor col = DyeColor.getColorFromDye(player.getHeldItemMainhand());
if (ConduitUtil.isProbeEquipped(player, hand)) {
if (!player.world.isRemote) {
// TODO PacketConduitProbe.sendInfoMessage(player, this);
}
return true;
} else if (col != null && res.component != null && isColorBandRendered(res.component.dir)) {
setExtractionSignalColor(res.component.dir, col);
return true;
} else if (ToolUtil.isToolEquipped(player, hand)) {
if (!getBundle().getEntity().getWorld().isRemote) {
if (res != null && res.component != null) {
EnumFacing connDir = res.component.dir;
EnumFacing faceHit = res.movingObjectPosition.sideHit;
if (connDir == null || connDir == faceHit) {
if (getConnectionMode(faceHit) == ConnectionMode.DISABLED) {
setConnectionMode(faceHit, getNextConnectionMode(faceHit));
return true;
}
// Attempt to join networks
return ConduitUtil.connectConduits(this, faceHit);
} else if (externalConnections.contains(connDir)) {
setConnectionMode(connDir, getNextConnectionMode(connDir));
return true;
} else if (containsConduitConnection(connDir)) {
ConduitUtil.disconnectConduits(this, connDir);
return true;
}
}
}
}
return false;
}
use of com.enderio.core.common.util.DyeColor in project EnderIO by SleepyTrousers.
the class ItemConduit method writeToNBT.
@Override
public void writeToNBT(@Nonnull NBTTagCompound nbtRoot) {
super.writeToNBT(nbtRoot);
for (Entry<EnumFacing, IItemFilter> entry : inputFilters.entrySet()) {
if (entry.getValue() != null) {
IItemFilter f = entry.getValue();
if (!isDefault(f)) {
NBTTagCompound itemRoot = new NBTTagCompound();
FilterRegistry.writeFilterToNbt(f, itemRoot);
nbtRoot.setTag("inFilts." + entry.getKey().name(), itemRoot);
}
}
}
for (Entry<EnumFacing, ItemStack> entry : functionUpgrades.entrySet()) {
if (entry.getValue() != null) {
ItemStack up = entry.getValue();
NBTTagCompound itemRoot = new NBTTagCompound();
up.writeToNBT(itemRoot);
nbtRoot.setTag("functionUpgrades." + entry.getKey().name(), itemRoot);
}
}
for (Entry<EnumFacing, IItemFilter> entry : outputFilters.entrySet()) {
if (entry.getValue() != null) {
IItemFilter f = entry.getValue();
if (!isDefault(f)) {
NBTTagCompound itemRoot = new NBTTagCompound();
FilterRegistry.writeFilterToNbt(f, itemRoot);
nbtRoot.setTag("outFilts." + entry.getKey().name(), itemRoot);
}
}
}
for (Entry<EnumFacing, ItemStack> entry : inputFilterUpgrades.entrySet()) {
if (entry.getValue() != null) {
ItemStack up = entry.getValue();
IItemFilter filter = getInputFilter(entry.getKey());
FilterRegistry.writeFilterToStack(filter, up);
NBTTagCompound itemRoot = new NBTTagCompound();
up.writeToNBT(itemRoot);
nbtRoot.setTag("inputFilterUpgrades." + entry.getKey().name(), itemRoot);
}
}
for (Entry<EnumFacing, ItemStack> entry : outputFilterUpgrades.entrySet()) {
if (entry.getValue() != null) {
ItemStack up = entry.getValue();
IItemFilter filter = getOutputFilter(entry.getKey());
FilterRegistry.writeFilterToStack(filter, up);
NBTTagCompound itemRoot = new NBTTagCompound();
up.writeToNBT(itemRoot);
nbtRoot.setTag("outputFilterUpgrades." + entry.getKey().name(), itemRoot);
}
}
for (Entry<EnumFacing, RedstoneControlMode> entry : extractionModes.entrySet()) {
if (entry.getValue() != null) {
short ord = (short) entry.getValue().ordinal();
nbtRoot.setShort("extRM." + entry.getKey().name(), ord);
}
}
for (Entry<EnumFacing, DyeColor> entry : extractionColors.entrySet()) {
if (entry.getValue() != null) {
short ord = (short) entry.getValue().ordinal();
nbtRoot.setShort("extSC." + entry.getKey().name(), ord);
}
}
for (Entry<EnumFacing, Boolean> entry : selfFeed.entrySet()) {
if (entry.getValue() != null) {
nbtRoot.setBoolean("selfFeed." + entry.getKey().name(), entry.getValue());
}
}
for (Entry<EnumFacing, Boolean> entry : roundRobin.entrySet()) {
if (entry.getValue() != null) {
nbtRoot.setBoolean("roundRobin." + entry.getKey().name(), entry.getValue());
}
}
for (Entry<EnumFacing, Integer> entry : priority.entrySet()) {
if (entry.getValue() != null) {
nbtRoot.setInteger("priority." + entry.getKey().name(), entry.getValue());
}
}
for (Entry<EnumFacing, DyeColor> entry : inputColors.entrySet()) {
if (entry.getValue() != null) {
short ord = (short) entry.getValue().ordinal();
nbtRoot.setShort("inSC." + entry.getKey().name(), ord);
}
}
for (Entry<EnumFacing, DyeColor> entry : outputColors.entrySet()) {
if (entry.getValue() != null) {
short ord = (short) entry.getValue().ordinal();
nbtRoot.setShort("outSC." + entry.getKey().name(), ord);
}
}
}
use of com.enderio.core.common.util.DyeColor in project EnderIO by SleepyTrousers.
the class ItemConduitRenderer method addConduitQuads.
@Override
protected void addConduitQuads(@Nonnull IConduitBundle bundle, @Nonnull IConduit conduit, @Nonnull TextureAtlasSprite tex, @Nonnull CollidableComponent component, float selfIllum, BlockRenderLayer layer, @Nonnull List<BakedQuad> quads) {
super.addConduitQuads(bundle, conduit, tex, component, selfIllum, layer, quads);
if (layer == null || component.dir == null) {
return;
}
EnumFacing dir = component.dir;
if (!conduit.getExternalConnections().contains(dir)) {
return;
}
IItemConduit pc = (IItemConduit) conduit;
DyeColor inChannel = null;
DyeColor outChannel = null;
TextureAtlasSprite inTex = null;
TextureAtlasSprite outTex = null;
boolean render = true;
if (conduit.getConnectionMode(dir) == ConnectionMode.INPUT) {
inTex = pc.getTextureForInputMode();
inChannel = pc.getInputColor(dir);
} else if (conduit.getConnectionMode(dir) == ConnectionMode.OUTPUT) {
outTex = pc.getTextureForOutputMode();
outChannel = pc.getOutputColor(dir);
} else if (conduit.getConnectionMode(dir) == ConnectionMode.IN_OUT) {
inTex = pc.getTextureForInOutMode(true);
outTex = pc.getTextureForInOutMode(false);
inChannel = pc.getInputColor(dir);
outChannel = pc.getOutputColor(dir);
} else {
render = false;
}
if (render) {
Offset offset = bundle.getOffset(IItemConduit.class, dir);
ConnectionModeGeometry.addModeConnectorQuads(dir, offset, pc.getTextureForInOutBackground(), null, quads);
if (inChannel != null) {
ConnectionModeGeometry.addModeConnectorQuads(dir, offset, inTex, ColorUtil.toFloat4(inChannel.getColor()), quads);
}
if (outChannel != null) {
ConnectionModeGeometry.addModeConnectorQuads(dir, offset, outTex, ColorUtil.toFloat4(outChannel.getColor()), quads);
}
}
}
use of com.enderio.core.common.util.DyeColor in project EnderIO by SleepyTrousers.
the class ItemSettings method actionPerformed.
@Override
public void actionPerformed(@Nonnull GuiButton guiButton) {
super.actionPerformed(guiButton);
if (guiButton.id == ID_COLOR_BUTTON) {
itemConduit.setExtractionSignalColor(gui.getDir(), DyeColor.fromIndex(colorB.getColorIndex()));
PacketHandler.INSTANCE.sendToServer(new PacketExtractMode(itemConduit, gui.getDir()));
return;
} else if (guiButton.id == ID_LOOP) {
itemConduit.setSelfFeedEnabled(gui.getDir(), !itemConduit.isSelfFeedEnabled(gui.getDir()));
} else if (guiButton.id == ID_ROUND_ROBIN) {
itemConduit.setRoundRobinEnabled(gui.getDir(), !itemConduit.isRoundRobinEnabled(gui.getDir()));
} else if (guiButton.id == ID_PRIORITY_UP) {
itemConduit.setOutputPriority(gui.getDir(), itemConduit.getOutputPriority(gui.getDir()) + 1);
} else if (guiButton.id == ID_PRIORITY_DOWN) {
itemConduit.setOutputPriority(gui.getDir(), itemConduit.getOutputPriority(gui.getDir()) - 1);
} else if (guiButton.id == ID_INSERT_CHANNEL) {
DyeColor col = DyeColor.values()[insertChannelB.getColorIndex()];
itemConduit.setOutputColor(gui.getDir(), col);
} else if (guiButton.id == ID_EXTRACT_CHANNEL) {
DyeColor col = DyeColor.values()[extractChannelB.getColorIndex()];
itemConduit.setInputColor(gui.getDir(), col);
} else if (guiButton.id == ID_INSERT_FILTER_OPTIONS) {
doOpenFilterGui(FilterGuiUtil.INDEX_OUTPUT);
return;
} else if (guiButton.id == ID_EXTRACT_FILTER_OPTIONS) {
doOpenFilterGui(FilterGuiUtil.INDEX_INPUT);
return;
}
PacketHandler.INSTANCE.sendToServer(new PacketItemConduitFilter(itemConduit, gui.getDir()));
}
Aggregations