mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
6dc3ebaf51
@ -11,7 +11,7 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class BlockEnumMulti extends BlockBase {
|
||||
public class BlockEnumMulti extends BlockMulti {
|
||||
|
||||
public Class<? extends Enum> theEnum;
|
||||
public boolean multiName;
|
||||
@ -23,19 +23,6 @@ public class BlockEnumMulti extends BlockBase {
|
||||
this.multiName = multiName;
|
||||
this.multiTexture = multiTexture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int meta) {
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
|
||||
for(int i = 0; i < theEnum.getEnumConstants().length; ++i) {
|
||||
list.add(new ItemStack(item, 1, i));
|
||||
}
|
||||
}
|
||||
|
||||
private IIcon[] icons;
|
||||
|
||||
@ -61,4 +48,9 @@ public class BlockEnumMulti extends BlockBase {
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return this.icons[meta % this.icons.length];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSubCount() {
|
||||
return this.theEnum.getEnumConstants().length;
|
||||
}
|
||||
}
|
||||
|
||||
40
src/main/java/com/hbm/blocks/BlockMulti.java
Normal file
40
src/main/java/com/hbm/blocks/BlockMulti.java
Normal file
@ -0,0 +1,40 @@
|
||||
package com.hbm.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public abstract class BlockMulti extends BlockBase {
|
||||
|
||||
public BlockMulti() {
|
||||
super();
|
||||
}
|
||||
|
||||
public BlockMulti(Material mat) {
|
||||
super(mat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int meta) {
|
||||
return rectify(meta);
|
||||
}
|
||||
|
||||
protected int rectify(int meta) {
|
||||
return Math.abs(meta % getSubCount());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
|
||||
for(int i = 0; i < getSubCount(); ++i) {
|
||||
list.add(new ItemStack(item, 1, i));
|
||||
}
|
||||
}
|
||||
|
||||
public abstract int getSubCount();
|
||||
}
|
||||
77
src/main/java/com/hbm/blocks/network/FluidDuctBase.java
Normal file
77
src/main/java/com/hbm/blocks/network/FluidDuctBase.java
Normal file
@ -0,0 +1,77 @@
|
||||
package com.hbm.blocks.network;
|
||||
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.items.machine.IItemFluidIdentifier;
|
||||
import com.hbm.tileentity.network.TileEntityPipeBaseNT;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class FluidDuctBase extends BlockContainer implements IBlockFluidDuct {
|
||||
|
||||
protected FluidDuctBase(Material mat) {
|
||||
super(mat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileEntityPipeBaseNT();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float fX, float fY, float fZ) {
|
||||
|
||||
if(player.getHeldItem() != null && player.getHeldItem().getItem() instanceof IItemFluidIdentifier) {
|
||||
IItemFluidIdentifier id = (IItemFluidIdentifier) player.getHeldItem().getItem();
|
||||
FluidType type = id.getType(world, x, y, z, player.getHeldItem());
|
||||
|
||||
if(!player.isSneaking()) {
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
if(te instanceof TileEntityPipeBaseNT) {
|
||||
TileEntityPipeBaseNT pipe = (TileEntityPipeBaseNT) te;
|
||||
|
||||
if(pipe.getType() != type) {
|
||||
pipe.setType(type);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
changeTypeRecursively(world, x, y, z, type, 64);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeTypeRecursively(World world, int x, int y, int z, FluidType type, int loopsRemaining) {
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
if(te instanceof TileEntityPipeBaseNT) {
|
||||
TileEntityPipeBaseNT pipe = (TileEntityPipeBaseNT) te;
|
||||
|
||||
if(pipe.getType() != type) {
|
||||
pipe.setType(type);
|
||||
|
||||
if(loopsRemaining > 0) {
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
Block b = world.getBlock(x, y, z);
|
||||
|
||||
if(b instanceof IBlockFluidDuct) {
|
||||
((IBlockFluidDuct) b).changeTypeRecursively(world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, type, loopsRemaining - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
50
src/main/java/com/hbm/blocks/network/FluidDuctStandard.java
Normal file
50
src/main/java/com/hbm/blocks/network/FluidDuctStandard.java
Normal file
@ -0,0 +1,50 @@
|
||||
package com.hbm.blocks.network;
|
||||
|
||||
import com.hbm.lib.RefStrings;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class FluidDuctStandard extends FluidDuctBase {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected IIcon[] icon;
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected IIcon[] overlay;
|
||||
|
||||
protected FluidDuctStandard(Material mat) {
|
||||
super(mat);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
super.registerBlockIcons(iconRegister);
|
||||
icon = new IIcon[3];
|
||||
overlay = new IIcon[3];
|
||||
|
||||
this.icon[0] = iconRegister.registerIcon(this.getTextureName());
|
||||
this.icon[1] = iconRegister.registerIcon(RefStrings.MODID + ":pipe_silver");
|
||||
this.icon[2] = iconRegister.registerIcon(RefStrings.MODID + ":pipe_colored");
|
||||
this.overlay[0] = iconRegister.registerIcon(this.getTextureName() + "_overlay");
|
||||
this.overlay[1] = iconRegister.registerIcon(RefStrings.MODID + ":pipe_silver_overlay");
|
||||
this.overlay[2] = iconRegister.registerIcon(RefStrings.MODID + ":pipe_colored_overlay");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
return side == 0 ? this.icon[rectify(metadata)] : this.overlay[rectify(metadata)];
|
||||
}
|
||||
|
||||
public int damageDropped(int meta) {
|
||||
return rectify(meta);
|
||||
}
|
||||
|
||||
private int rectify(int meta) {
|
||||
return Math.abs(meta % 3);
|
||||
}
|
||||
}
|
||||
10
src/main/java/com/hbm/blocks/network/IBlockFluidDuct.java
Normal file
10
src/main/java/com/hbm/blocks/network/IBlockFluidDuct.java
Normal file
@ -0,0 +1,10 @@
|
||||
package com.hbm.blocks.network;
|
||||
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IBlockFluidDuct {
|
||||
|
||||
public void changeTypeRecursively(World world, int x, int y, int z, FluidType type, int loopsRemaining);
|
||||
}
|
||||
@ -3,6 +3,7 @@ package com.hbm.items.block;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.blocks.BlockEnumMulti;
|
||||
import com.hbm.blocks.BlockMulti;
|
||||
import com.hbm.blocks.ITooltipProvider;
|
||||
import com.hbm.util.EnumUtil;
|
||||
|
||||
@ -17,7 +18,7 @@ public class ItemBlockBase extends ItemBlock {
|
||||
public ItemBlockBase(Block block) {
|
||||
super(block);
|
||||
|
||||
if(block instanceof BlockEnumMulti) {
|
||||
if(block instanceof BlockMulti) {
|
||||
this.setMaxDamage(0);
|
||||
this.setHasSubtypes(true);
|
||||
}
|
||||
@ -25,7 +26,7 @@ public class ItemBlockBase extends ItemBlock {
|
||||
|
||||
@Override
|
||||
public int getMetadata(int meta) {
|
||||
if(field_150939_a instanceof BlockEnumMulti)
|
||||
if(field_150939_a instanceof BlockMulti)
|
||||
return meta;
|
||||
else
|
||||
return super.getMetadata(meta);
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
package com.hbm.items.machine;
|
||||
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IItemFluidIdentifier {
|
||||
|
||||
public FluidType getType(World world, int x, int y, int z, ItemStack stack);
|
||||
}
|
||||
@ -25,7 +25,7 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class ItemFluidIdentifier extends Item {
|
||||
public class ItemFluidIdentifier extends Item implements IItemFluidIdentifier {
|
||||
|
||||
IIcon overlayIcon;
|
||||
|
||||
@ -80,6 +80,11 @@ public class ItemFluidIdentifier extends Item {
|
||||
return Fluids.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidType getType(World world, int x, int y, int z, ItemStack stack) {
|
||||
return Fluids.fromID(stack.getItemDamage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int i, float f1, float f2, float f3) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
@ -108,6 +113,7 @@ public class ItemFluidIdentifier extends Item {
|
||||
markDuctsRecursively(world, x, y, z, type, 64);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private void markDuctsRecursively(World world, int x, int y, int z, FluidType type, int maxRecursion) {
|
||||
TileEntity start = world.getTileEntity(x, y, z);
|
||||
|
||||
@ -183,5 +189,4 @@ public class ItemFluidIdentifier extends Item {
|
||||
return j;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -3,16 +3,16 @@ package com.hbm.render.block;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.blocks.test.TestPipe;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.main.ResourceManager;
|
||||
import com.hbm.render.util.ObjUtil;
|
||||
import com.hbm.tileentity.network.TileEntityPipeBaseNT;
|
||||
|
||||
import api.hbm.fluid.IFluidConductor;
|
||||
import api.hbm.fluid.IFluidConnector;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.model.obj.WavefrontObject;
|
||||
@ -58,18 +58,24 @@ public class RenderTestPipe implements ISimpleBlockRenderingHandler {
|
||||
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
|
||||
tessellator.setColorOpaque_F(1, 1, 1);
|
||||
|
||||
boolean pX = world.getTileEntity(x + 1, y, z) instanceof IFluidConductor;
|
||||
boolean nX = world.getTileEntity(x - 1, y, z) instanceof IFluidConductor;
|
||||
boolean pY = world.getTileEntity(x, y + 1, z) instanceof IFluidConductor;
|
||||
boolean nY = world.getTileEntity(x, y - 1, z) instanceof IFluidConductor;
|
||||
boolean pZ = world.getTileEntity(x, y, z + 1) instanceof IFluidConductor;
|
||||
boolean nZ = world.getTileEntity(x, y, z - 1) instanceof IFluidConductor;
|
||||
boolean pX = world.getTileEntity(x + 1, y, z) instanceof IFluidConnector;
|
||||
boolean nX = world.getTileEntity(x - 1, y, z) instanceof IFluidConnector;
|
||||
boolean pY = world.getTileEntity(x, y + 1, z) instanceof IFluidConnector;
|
||||
boolean nY = world.getTileEntity(x, y - 1, z) instanceof IFluidConnector;
|
||||
boolean pZ = world.getTileEntity(x, y, z + 1) instanceof IFluidConnector;
|
||||
boolean nZ = world.getTileEntity(x, y, z - 1) instanceof IFluidConnector;
|
||||
|
||||
int mask = 0 + (pX ? 32 : 0) + (nX ? 16 : 0) + (pY ? 8 : 0) + (nY ? 4 : 0) + (pZ ? 2 : 0) + (nZ ? 1 : 0);
|
||||
|
||||
tessellator.addTranslation(x + 0.5F, y + 0.5F, z + 0.5F);
|
||||
|
||||
int color = 0xff0000;
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
int color = 0xff00ff;
|
||||
|
||||
if(te instanceof TileEntityPipeBaseNT) {
|
||||
color = ((TileEntityPipeBaseNT) te).getType().getColor();
|
||||
}
|
||||
|
||||
if(mask == 0) {
|
||||
renderDuct(iicon, overlay, color, tessellator, "pX");
|
||||
@ -96,14 +102,14 @@ public class RenderTestPipe implements ISimpleBlockRenderingHandler {
|
||||
if(pZ) renderDuct(iicon, overlay, color, tessellator, "nZ");
|
||||
if(nZ) renderDuct(iicon, overlay, color, tessellator, "pZ");
|
||||
|
||||
if(!pX && !pY && !pZ) ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.pipe_neo, "ppn", iicon, tessellator, 0, true);
|
||||
if(!pX && !pY && !nZ) ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.pipe_neo, "ppp", iicon, tessellator, 0, true);
|
||||
if(!nX && !pY && !pZ) ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.pipe_neo, "npn", iicon, tessellator, 0, true);
|
||||
if(!nX && !pY && !nZ) ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.pipe_neo, "npp", iicon, tessellator, 0, true);
|
||||
if(!pX && !nY && !pZ) ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.pipe_neo, "pnn", iicon, tessellator, 0, true);
|
||||
if(!pX && !nY && !nZ) ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.pipe_neo, "pnp", iicon, tessellator, 0, true);
|
||||
if(!nX && !nY && !pZ) ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.pipe_neo, "nnn", iicon, tessellator, 0, true);
|
||||
if(!nX && !nY && !nZ) ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.pipe_neo, "nnp", iicon, tessellator, 0, true);
|
||||
if(!pX && !pY && !pZ) renderDuct(iicon, overlay, color, tessellator, "ppn");
|
||||
if(!pX && !pY && !nZ) renderDuct(iicon, overlay, color, tessellator, "ppp");
|
||||
if(!nX && !pY && !pZ) renderDuct(iicon, overlay, color, tessellator, "npn");
|
||||
if(!nX && !pY && !nZ) renderDuct(iicon, overlay, color, tessellator, "npp");
|
||||
if(!pX && !nY && !pZ) renderDuct(iicon, overlay, color, tessellator, "pnn");
|
||||
if(!pX && !nY && !nZ) renderDuct(iicon, overlay, color, tessellator, "pnp");
|
||||
if(!nX && !nY && !pZ) renderDuct(iicon, overlay, color, tessellator, "nnn");
|
||||
if(!nX && !nY && !nZ) renderDuct(iicon, overlay, color, tessellator, "nnp");
|
||||
}
|
||||
|
||||
tessellator.addTranslation(-x - 0.5F, -y - 0.5F, -z - 0.5F);
|
||||
|
||||
@ -6,13 +6,15 @@ import com.hbm.inventory.fluid.Fluids;
|
||||
import api.hbm.fluid.IFluidConductor;
|
||||
import api.hbm.fluid.IPipeNet;
|
||||
import api.hbm.fluid.PipeNet;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityPipeBaseNT extends TileEntity implements IFluidConductor {
|
||||
|
||||
private IPipeNet network;
|
||||
protected FluidType type = Fluids.WATER;
|
||||
protected FluidType type = Fluids.NONE;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
@ -30,6 +32,20 @@ public class TileEntityPipeBaseNT extends TileEntity implements IFluidConductor
|
||||
}
|
||||
}
|
||||
|
||||
public FluidType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public void setType(FluidType type) {
|
||||
this.type = type;
|
||||
this.markDirty();
|
||||
|
||||
if(worldObj instanceof WorldServer) {
|
||||
WorldServer world = (WorldServer) worldObj;
|
||||
world.getPlayerManager().markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
protected void connect() {
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
@ -96,4 +112,16 @@ public class TileEntityPipeBaseNT extends TileEntity implements IFluidConductor
|
||||
public void setPipeNet(FluidType type, IPipeNet network) {
|
||||
this.network = network;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
this.type = Fluids.fromID(nbt.getInteger("type"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setInteger("type", this.type.getID());
|
||||
}
|
||||
}
|
||||
|
||||
BIN
src/main/resources/assets/hbm/textures/blocks/pipe_colored.png
Normal file
BIN
src/main/resources/assets/hbm/textures/blocks/pipe_colored.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 168 B |
Binary file not shown.
|
After Width: | Height: | Size: 193 B |
BIN
src/main/resources/assets/hbm/textures/blocks/pipe_silver.png
Normal file
BIN
src/main/resources/assets/hbm/textures/blocks/pipe_silver.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 238 B |
Binary file not shown.
|
After Width: | Height: | Size: 102 B |
Loading…
x
Reference in New Issue
Block a user