mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
paintable pylon wires
This commit is contained in:
parent
ef169ac06e
commit
5b41c3d83a
@ -1,4 +1,3 @@
|
|||||||
## Fixed
|
## Changed
|
||||||
* Fixed battery connection priority being broken, all battery blocks present during the previous updates will now have their priority default to LOW
|
* All pylons and electrical connectors are now dyeable, using any dye (even modded ones, based on ore dict) to change the color of the cable
|
||||||
* Fixed batteries sometimes ending up transferring themselves, wasting their entire receiving and sending speed on doing effectively nothing
|
* Colors are based on the connecting pylon, not the cables themselves, meaning that using one dye will change all wires connected to that pylon right up to the half way point
|
||||||
* Energy tracking is still a bit flakey so there could be issues that remain with buffer mode batteries, however the transfer caps should mitigate most potential issues
|
|
||||||
@ -6,6 +6,7 @@ import com.hbm.tileentity.network.TileEntityPylonBase;
|
|||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockContainer;
|
import net.minecraft.block.BlockContainer;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
@ -41,4 +42,16 @@ public abstract class PylonBase extends BlockContainer implements ITooltipProvid
|
|||||||
public boolean renderAsNormalBlock() {
|
public boolean renderAsNormalBlock() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||||
|
if(world.isRemote) {
|
||||||
|
return true;
|
||||||
|
} else if(!player.isSneaking()) {
|
||||||
|
TileEntityPylonBase te = (TileEntityPylonBase) world.getTileEntity(x, y, z);
|
||||||
|
return te.setColor(player.getHeldItem());
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -82,4 +82,17 @@ public class PylonLarge extends BlockDummyable implements ITooltipProvider {
|
|||||||
|
|
||||||
return dir.ordinal() + offset;
|
return dir.ordinal() + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||||
|
if(world.isRemote) {
|
||||||
|
return true;
|
||||||
|
} else if(!player.isSneaking()) {
|
||||||
|
int[] pos = this.findCore(world, x, y, z);
|
||||||
|
TileEntityPylonBase te = (TileEntityPylonBase) world.getTileEntity(pos[0], pos[1], pos[2]);
|
||||||
|
return te.setColor(player.getHeldItem());
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,4 +50,17 @@ public class PylonMedium extends BlockDummyable implements ITooltipProvider {
|
|||||||
if(te instanceof TileEntityPylonBase) ((TileEntityPylonBase)te).disconnectAll();
|
if(te instanceof TileEntityPylonBase) ((TileEntityPylonBase)te).disconnectAll();
|
||||||
super.breakBlock(world, x, y, z, b, m);
|
super.breakBlock(world, x, y, z, b, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||||
|
if(world.isRemote) {
|
||||||
|
return true;
|
||||||
|
} else if(!player.isSneaking()) {
|
||||||
|
int[] pos = this.findCore(world, x, y, z);
|
||||||
|
TileEntityPylonBase te = (TileEntityPylonBase) world.getTileEntity(pos[0], pos[1], pos[2]);
|
||||||
|
return te.setColor(player.getHeldItem());
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -72,4 +72,17 @@ public class Substation extends BlockDummyable implements ITooltipProvider {
|
|||||||
this.makeExtra(world, x + dir.offsetX * o - 1, y, z + dir.offsetZ * o + 1);
|
this.makeExtra(world, x + dir.offsetX * o - 1, y, z + dir.offsetZ * o + 1);
|
||||||
this.makeExtra(world, x + dir.offsetX * o - 1, y, z + dir.offsetZ * o - 1);
|
this.makeExtra(world, x + dir.offsetX * o - 1, y, z + dir.offsetZ * o - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||||
|
if(world.isRemote) {
|
||||||
|
return true;
|
||||||
|
} else if(!player.isSneaking()) {
|
||||||
|
int[] pos = this.findCore(world, x, y, z);
|
||||||
|
TileEntityPylonBase te = (TileEntityPylonBase) world.getTileEntity(pos[0], pos[1], pos[2]);
|
||||||
|
return te.setColor(player.getHeldItem());
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -788,6 +788,7 @@ public class ResourceManager {
|
|||||||
public static final ResourceLocation pylon_large_tex = new ResourceLocation(RefStrings.MODID, "textures/models/network/pylon_large.png");
|
public static final ResourceLocation pylon_large_tex = new ResourceLocation(RefStrings.MODID, "textures/models/network/pylon_large.png");
|
||||||
public static final ResourceLocation substation_tex = new ResourceLocation(RefStrings.MODID, "textures/models/network/substation.png");
|
public static final ResourceLocation substation_tex = new ResourceLocation(RefStrings.MODID, "textures/models/network/substation.png");
|
||||||
public static final ResourceLocation wire_tex = new ResourceLocation(RefStrings.MODID, "textures/models/network/wire.png");
|
public static final ResourceLocation wire_tex = new ResourceLocation(RefStrings.MODID, "textures/models/network/wire.png");
|
||||||
|
public static final ResourceLocation wire_greyscale_tex = new ResourceLocation(RefStrings.MODID, "textures/models/network/wire_greyscale.png");
|
||||||
|
|
||||||
//Radiolysis
|
//Radiolysis
|
||||||
public static final ResourceLocation radiolysis_tex = new ResourceLocation(RefStrings.MODID, "textures/models/radiolysis.png");
|
public static final ResourceLocation radiolysis_tex = new ResourceLocation(RefStrings.MODID, "textures/models/radiolysis.png");
|
||||||
|
|||||||
@ -24,7 +24,7 @@ public abstract class RenderPylonBase extends TileEntitySpecialRenderer {
|
|||||||
*/
|
*/
|
||||||
public void renderLinesGeneric(TileEntityPylonBase pyl, double x, double y, double z) {
|
public void renderLinesGeneric(TileEntityPylonBase pyl, double x, double y, double z) {
|
||||||
|
|
||||||
this.bindTexture(ResourceManager.wire_tex);
|
this.bindTexture(pyl.color == 0 ? ResourceManager.wire_tex : ResourceManager.wire_greyscale_tex);
|
||||||
|
|
||||||
for(int i = 0; i < pyl.connected.size(); i++) {
|
for(int i = 0; i < pyl.connected.size(); i++) {
|
||||||
|
|
||||||
@ -127,6 +127,8 @@ public abstract class RenderPylonBase extends TileEntitySpecialRenderer {
|
|||||||
int brightness = world.getLightBrightnessForSkyBlocks(MathHelper.floor_double(ix), MathHelper.floor_double(iy), MathHelper.floor_double(iz), 0);
|
int brightness = world.getLightBrightnessForSkyBlocks(MathHelper.floor_double(ix), MathHelper.floor_double(iy), MathHelper.floor_double(iz), 0);
|
||||||
tess.setBrightness(brightness);
|
tess.setBrightness(brightness);
|
||||||
|
|
||||||
|
tess.setColorOpaque_I(pyl.color == 0 ? 0xffffff : pyl.color);
|
||||||
|
|
||||||
drawLineSegment(tess,
|
drawLineSegment(tess,
|
||||||
x0 + (deltaX * j / count),
|
x0 + (deltaX * j / count),
|
||||||
y0 + (deltaY * j / count) - sagJ,
|
y0 + (deltaY * j / count) - sagJ,
|
||||||
@ -180,7 +182,6 @@ public abstract class RenderPylonBase extends TileEntitySpecialRenderer {
|
|||||||
jX *= -1;
|
jX *= -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tessellator.setColorOpaque_I(0xffffff);
|
|
||||||
tessellator.addVertexWithUV(x + iX, y + iY, z + iZ, 0, 0);
|
tessellator.addVertexWithUV(x + iX, y + iY, z + iZ, 0, 0);
|
||||||
tessellator.addVertexWithUV(x - iX, y - iY, z - iZ, 0, 1);
|
tessellator.addVertexWithUV(x - iX, y - iY, z - iZ, 0, 1);
|
||||||
tessellator.addVertexWithUV(a - iX, b - iY, c - iZ, wrap, 1);
|
tessellator.addVertexWithUV(a - iX, b - iY, c - iZ, wrap, 1);
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package com.hbm.tileentity.network;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.hbm.util.ColorUtil;
|
||||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||||
|
|
||||||
@ -10,6 +11,7 @@ import api.hbm.energymk2.Nodespace;
|
|||||||
import api.hbm.energymk2.Nodespace.PowerNode;
|
import api.hbm.energymk2.Nodespace.PowerNode;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.network.NetworkManager;
|
import net.minecraft.network.NetworkManager;
|
||||||
import net.minecraft.network.Packet;
|
import net.minecraft.network.Packet;
|
||||||
@ -23,6 +25,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||||||
public abstract class TileEntityPylonBase extends TileEntityCableBaseNT {
|
public abstract class TileEntityPylonBase extends TileEntityCableBaseNT {
|
||||||
|
|
||||||
public List<int[]> connected = new ArrayList<int[]>();
|
public List<int[]> connected = new ArrayList<int[]>();
|
||||||
|
public int color;
|
||||||
|
|
||||||
public static int canConnect(TileEntityPylonBase first, TileEntityPylonBase second) {
|
public static int canConnect(TileEntityPylonBase first, TileEntityPylonBase second) {
|
||||||
|
|
||||||
@ -46,6 +49,22 @@ public abstract class TileEntityPylonBase extends TileEntityCableBaseNT {
|
|||||||
return len >= delta.lengthVector() ? 0 : 3;
|
return len >= delta.lengthVector() ? 0 : 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean setColor(ItemStack stack) {
|
||||||
|
if(stack == null) return false;
|
||||||
|
int color = ColorUtil.getColorFromDye(stack);
|
||||||
|
if(color == 0 || color == this.color) return false;
|
||||||
|
stack.stackSize--;
|
||||||
|
this.color = color;
|
||||||
|
|
||||||
|
this.markDirty();
|
||||||
|
if(worldObj instanceof WorldServer) {
|
||||||
|
WorldServer world = (WorldServer) worldObj;
|
||||||
|
world.getPlayerManager().markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PowerNode createNode() {
|
public PowerNode createNode() {
|
||||||
TileEntity tile = (TileEntity) this;
|
TileEntity tile = (TileEntity) this;
|
||||||
@ -122,6 +141,7 @@ public abstract class TileEntityPylonBase extends TileEntityCableBaseNT {
|
|||||||
super.writeToNBT(nbt);
|
super.writeToNBT(nbt);
|
||||||
|
|
||||||
nbt.setInteger("conCount", connected.size());
|
nbt.setInteger("conCount", connected.size());
|
||||||
|
nbt.setInteger("color", color);
|
||||||
|
|
||||||
for(int i = 0; i < connected.size(); i++) {
|
for(int i = 0; i < connected.size(); i++) {
|
||||||
nbt.setIntArray("con" + i, connected.get(i));
|
nbt.setIntArray("con" + i, connected.get(i));
|
||||||
@ -133,6 +153,7 @@ public abstract class TileEntityPylonBase extends TileEntityCableBaseNT {
|
|||||||
super.readFromNBT(nbt);
|
super.readFromNBT(nbt);
|
||||||
|
|
||||||
int count = nbt.getInteger("conCount");
|
int count = nbt.getInteger("conCount");
|
||||||
|
this.color = nbt.getInteger("color");
|
||||||
|
|
||||||
this.connected.clear();
|
this.connected.clear();
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
|
||||||
@ -182,4 +183,36 @@ public class ColorUtil {
|
|||||||
float[] hsb = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), new float[3]);
|
float[] hsb = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), new float[3]);
|
||||||
return hsb[2];
|
return hsb[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static HashMap<String, Integer> nameToColor = new HashMap() {{
|
||||||
|
put("black", 1973019);
|
||||||
|
put("red", 11743532);
|
||||||
|
put("green", 3887386);
|
||||||
|
put("brown", 5320730);
|
||||||
|
put("blue", 2437522);
|
||||||
|
put("purple", 8073150);
|
||||||
|
put("cyan", 2651799);
|
||||||
|
put("silver", 11250603);
|
||||||
|
put("gray", 4408131);
|
||||||
|
put("pink", 14188952);
|
||||||
|
put("lime", 4312372);
|
||||||
|
put("yellow", 14602026);
|
||||||
|
put("lightBlue", 6719955);
|
||||||
|
put("magenta", 12801229);
|
||||||
|
put("orange", 15435844);
|
||||||
|
put("white", 15790320);
|
||||||
|
}};
|
||||||
|
|
||||||
|
public static int getColorFromDye(ItemStack stack) {
|
||||||
|
List<String> oreNames = ItemStackUtil.getOreDictNames(stack);
|
||||||
|
|
||||||
|
for(String dict : oreNames) {
|
||||||
|
if(dict.length() > 3 && dict.startsWith("dye")) {
|
||||||
|
String color = dict.substring(3).toLowerCase(Locale.US);
|
||||||
|
if(nameToColor.containsKey(color)) return nameToColor.get(color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
src/main/resources/assets/hbm/textures/items/card_hbm.png
Normal file
BIN
src/main/resources/assets/hbm/textures/items/card_hbm.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
BIN
src/main/resources/assets/hbm/textures/items/kit_hbm.png
Normal file
BIN
src/main/resources/assets/hbm/textures/items/kit_hbm.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 137 B |
Loading…
x
Reference in New Issue
Block a user