mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-08-10 17:55:44 +00:00
the clicky bits
This commit is contained in:
parent
fa6f54f01a
commit
551140d130
@ -16,9 +16,13 @@ public interface ITooltipProvider {
|
|||||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext);
|
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext);
|
||||||
|
|
||||||
public default void addStandardInfo(ItemStack stack, EntityPlayer player, List list, boolean ext) {
|
public default void addStandardInfo(ItemStack stack, EntityPlayer player, List list, boolean ext) {
|
||||||
|
this.addStandardInfo(stack, ((Block) this).getUnlocalizedName() + ".desc", player, list, ext);
|
||||||
|
}
|
||||||
|
|
||||||
|
public default void addStandardInfo(ItemStack stack, String name, EntityPlayer player, List list, boolean ext) {
|
||||||
|
|
||||||
if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
|
if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
|
||||||
for(String s : I18nUtil.resolveKeyArray(((Block)this).getUnlocalizedName() + ".desc")) list.add(EnumChatFormatting.YELLOW + s);
|
for(String s : I18nUtil.resolveKeyArray(name)) list.add(EnumChatFormatting.YELLOW + s);
|
||||||
} else {
|
} else {
|
||||||
list.add(EnumChatFormatting.DARK_GRAY + "" + EnumChatFormatting.ITALIC +"Hold <" +
|
list.add(EnumChatFormatting.DARK_GRAY + "" + EnumChatFormatting.ITALIC +"Hold <" +
|
||||||
EnumChatFormatting.YELLOW + "" + EnumChatFormatting.ITALIC + "LSHIFT" +
|
EnumChatFormatting.YELLOW + "" + EnumChatFormatting.ITALIC + "LSHIFT" +
|
||||||
|
|||||||
@ -1,7 +1,10 @@
|
|||||||
package com.hbm.blocks.machine.pile;
|
package com.hbm.blocks.machine.pile;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import com.hbm.blocks.ILookOverlay;
|
||||||
import com.hbm.blocks.ModBlocks;
|
import com.hbm.blocks.ModBlocks;
|
||||||
import com.hbm.blocks.machine.MachinePWRController;
|
import com.hbm.blocks.machine.MachinePWRController;
|
||||||
import com.hbm.lib.RefStrings;
|
import com.hbm.lib.RefStrings;
|
||||||
@ -10,6 +13,7 @@ import com.hbm.render.block.ct.CTStitchReceiver;
|
|||||||
import com.hbm.render.block.ct.IBlockCT;
|
import com.hbm.render.block.ct.IBlockCT;
|
||||||
import com.hbm.tileentity.machine.pile.TileEntityPileBaseMK2;
|
import com.hbm.tileentity.machine.pile.TileEntityPileBaseMK2;
|
||||||
import com.hbm.tileentity.machine.pile.TileEntityPileCore;
|
import com.hbm.tileentity.machine.pile.TileEntityPileCore;
|
||||||
|
import com.hbm.util.i18n.I18nUtil;
|
||||||
|
|
||||||
import api.hbm.block.IToolable;
|
import api.hbm.block.IToolable;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
@ -24,9 +28,10 @@ import net.minecraft.tileentity.TileEntity;
|
|||||||
import net.minecraft.util.IIcon;
|
import net.minecraft.util.IIcon;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
public class BlockPile extends BlockContainer implements IBlockCT, IToolable {
|
public class BlockPile extends BlockContainer implements IBlockCT, IToolable, ILookOverlay {
|
||||||
|
|
||||||
/** Blank dummy, the pile is mostly composed of that */
|
/** Blank dummy, the pile is mostly composed of that */
|
||||||
public static final int META_DUMMY = 0;
|
public static final int META_DUMMY = 0;
|
||||||
@ -123,6 +128,7 @@ public class BlockPile extends BlockContainer implements IBlockCT, IToolable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(tile instanceof TileEntityPileBaseMK2) {
|
if(tile instanceof TileEntityPileBaseMK2) {
|
||||||
|
if(world.isRemote) return true;
|
||||||
TileEntityPileCore core = ((TileEntityPileBaseMK2) tile).getCore();
|
TileEntityPileCore core = ((TileEntityPileBaseMK2) tile).getCore();
|
||||||
if(core != null) {
|
if(core != null) {
|
||||||
ForgeDirection dir = ForgeDirection.getOrientation(side).getOpposite();
|
ForgeDirection dir = ForgeDirection.getOrientation(side).getOpposite();
|
||||||
@ -135,4 +141,16 @@ public class BlockPile extends BlockContainer implements IBlockCT, IToolable {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void printHook(Pre event, World world, int x, int y, int z) {
|
||||||
|
int meta = world.getBlockMetadata(x, y, z);
|
||||||
|
List<String> text = new ArrayList();
|
||||||
|
if(meta == META_FUEL_IN) text.add("Fuel Loading Port");
|
||||||
|
if(meta == META_FUEL_OUT) text.add("Fuel Ejection Port");
|
||||||
|
if(meta == META_AIR_IN) text.add("Air Inlet");
|
||||||
|
if(meta == META_AIR_OUT) text.add("Air Outlet");
|
||||||
|
if(meta == META_CONTROL) text.add("Control Rod Channel");
|
||||||
|
if(!text.isEmpty()) ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,16 @@
|
|||||||
package com.hbm.blocks.machine.pile;
|
package com.hbm.blocks.machine.pile;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.hbm.blocks.IBlockMulti;
|
import com.hbm.blocks.IBlockMulti;
|
||||||
|
import com.hbm.blocks.ILookOverlay;
|
||||||
|
import com.hbm.blocks.ITooltipProvider;
|
||||||
|
import com.hbm.main.NTMSounds;
|
||||||
import com.hbm.tileentity.machine.pile.TileEntityPileControl;
|
import com.hbm.tileentity.machine.pile.TileEntityPileControl;
|
||||||
import com.hbm.tileentity.machine.pile.TileEntityPileLoader;
|
import com.hbm.tileentity.machine.pile.TileEntityPileLoader;
|
||||||
import com.hbm.tileentity.machine.pile.TileEntityPileVent;
|
import com.hbm.tileentity.machine.pile.TileEntityPileVent;
|
||||||
|
import com.hbm.util.i18n.I18nUtil;
|
||||||
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
@ -13,15 +18,17 @@ import net.minecraft.block.BlockContainer;
|
|||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
public class BlockPileDevice extends BlockContainer implements IBlockMulti {
|
public class BlockPileDevice extends BlockContainer implements IBlockMulti, ILookOverlay, ITooltipProvider {
|
||||||
|
|
||||||
public static final int ITEM_META_LOADER = 0;
|
public static final int ITEM_META_LOADER = 0;
|
||||||
public static final int ITEM_META_VENT = 1;
|
public static final int ITEM_META_VENT = 1;
|
||||||
@ -69,6 +76,35 @@ public class BlockPileDevice extends BlockContainer implements IBlockMulti {
|
|||||||
side = MathHelper.clamp_int(side - 2, 0, 3);
|
side = MathHelper.clamp_int(side - 2, 0, 3);
|
||||||
return metaOffset + side;
|
return metaOffset + side;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||||
|
int meta = world.getBlockMetadata(x, y, z);
|
||||||
|
meta -= meta % 4;
|
||||||
|
|
||||||
|
if(meta == BLOCK_META_LOADER) {
|
||||||
|
if(world.isRemote) return true;
|
||||||
|
|
||||||
|
TileEntityPileLoader tile = (TileEntityPileLoader) world.getTileEntity(x, y, z);
|
||||||
|
|
||||||
|
if(tile.level <= 0 && !tile.loading) {
|
||||||
|
|
||||||
|
if(player.getHeldItem() != null && tile.stack == null && tile.isItemLoadable(player.getHeldItem())) {
|
||||||
|
tile.stack = player.getHeldItem().copy();
|
||||||
|
tile.stack.stackSize = 1;
|
||||||
|
player.getHeldItem().stackSize--;
|
||||||
|
world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, NTMSounds.UPGRADE_PLUG, 1F, 1F);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
tile.loading = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {
|
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {
|
||||||
@ -101,4 +137,49 @@ public class BlockPileDevice extends BlockContainer implements IBlockMulti {
|
|||||||
|
|
||||||
return side.ordinal() == meta % 4 + 2;
|
return side.ordinal() == meta % 4 + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
|
||||||
|
this.addStandardInfo(stack, this.getUnlocalizedName(stack) + ".desc", player, list, ext);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void printHook(Pre event, World world, int x, int y, int z) {
|
||||||
|
int meta = world.getBlockMetadata(x, y, z);
|
||||||
|
|
||||||
|
List<String> text = new ArrayList();
|
||||||
|
TileEntity tile = world.getTileEntity(x, y, z);
|
||||||
|
|
||||||
|
if(tile instanceof TileEntityPileLoader) {
|
||||||
|
TileEntityPileLoader device = (TileEntityPileLoader) tile;
|
||||||
|
text.add("Index: " + device.chanNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(tile instanceof TileEntityPileVent) {
|
||||||
|
TileEntityPileVent device = (TileEntityPileVent) tile;
|
||||||
|
text.add("Index: " + device.chanNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(tile instanceof TileEntityPileControl) {
|
||||||
|
TileEntityPileControl device = (TileEntityPileControl) tile;
|
||||||
|
text.add("Extraction level: " + (int) + (device.level * 100) + "%");
|
||||||
|
text.add("Index: " + device.chanNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!text.isEmpty())
|
||||||
|
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedNameFromItemMeta(this.damageDropped(meta)) + ".name"), 0xffff00, 0x404000, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUnlocalizedName(ItemStack stack) {
|
||||||
|
return getUnlocalizedNameFromItemMeta(stack.getItemDamage());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUnlocalizedNameFromItemMeta(int meta) {
|
||||||
|
meta = Math.abs(meta % 3); // recitfy
|
||||||
|
if(meta == ITEM_META_LOADER) return this.getUnlocalizedName() + ".loader";
|
||||||
|
if(meta == ITEM_META_VENT) return this.getUnlocalizedName() + ".vent";
|
||||||
|
if(meta == ITEM_META_CONTROL) return this.getUnlocalizedName() + ".control";
|
||||||
|
return this.getUnlocalizedName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import com.hbm.blocks.ModBlocks;
|
|||||||
import com.hbm.blocks.machine.pile.BlockPileDevice;
|
import com.hbm.blocks.machine.pile.BlockPileDevice;
|
||||||
import com.hbm.main.ResourceManager;
|
import com.hbm.main.ResourceManager;
|
||||||
import com.hbm.render.item.ItemRenderBase;
|
import com.hbm.render.item.ItemRenderBase;
|
||||||
|
import com.hbm.tileentity.machine.pile.TileEntityPileLoader;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
@ -29,16 +30,21 @@ public class RenderPileLoader extends TileEntitySpecialRenderer implements IItem
|
|||||||
case 3: GL11.glRotated(0, 0, 1, 0); break;
|
case 3: GL11.glRotated(0, 0, 1, 0); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TileEntityPileLoader loader = (TileEntityPileLoader) te;
|
||||||
|
double position = loader.lastLevel + (loader.level - loader.lastLevel) * interp;
|
||||||
|
|
||||||
bindTexture(ResourceManager.pile_loader_tex);
|
bindTexture(ResourceManager.pile_loader_tex);
|
||||||
ResourceManager.pile_loader.renderPart("Loader");
|
ResourceManager.pile_loader.renderPart("Loader");
|
||||||
GL11.glPushMatrix(); {
|
GL11.glPushMatrix(); {
|
||||||
GL11.glTranslated(-0.1875, 0.5, 0);
|
GL11.glTranslated(-0.1875, 0.5, 0);
|
||||||
GL11.glRotated(90, 0, 0, 1);
|
GL11.glRotated(position * 90, 0, 0, 1);
|
||||||
GL11.glTranslated(0.1875, -0.5, 0);
|
GL11.glTranslated(0.1875, -0.5, 0);
|
||||||
ResourceManager.pile_loader.renderPart("Lever");
|
ResourceManager.pile_loader.renderPart("Lever");
|
||||||
} GL11.glPopMatrix();
|
} GL11.glPopMatrix();
|
||||||
|
|
||||||
|
GL11.glTranslated(position * -0.5, 0, 0);
|
||||||
ResourceManager.pile_loader.renderPart("Slider");
|
ResourceManager.pile_loader.renderPart("Slider");
|
||||||
ResourceManager.pile_loader.renderPart("Rod");
|
if(loader.hasRod) ResourceManager.pile_loader.renderPart("Rod");
|
||||||
|
|
||||||
GL11.glShadeModel(GL11.GL_FLAT);
|
GL11.glShadeModel(GL11.GL_FLAT);
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
@ -54,10 +60,11 @@ public class RenderPileLoader extends TileEntitySpecialRenderer implements IItem
|
|||||||
return new ItemRenderBase() {
|
return new ItemRenderBase() {
|
||||||
public void renderInventory() {
|
public void renderInventory() {
|
||||||
GL11.glTranslated(0, -3.5, 0);
|
GL11.glTranslated(0, -3.5, 0);
|
||||||
double scale = 10;
|
double scale = 5;
|
||||||
GL11.glScaled(scale, scale, scale);
|
GL11.glScaled(scale, scale, scale);
|
||||||
}
|
}
|
||||||
public void renderCommonWithStack(ItemStack item) {
|
public void renderCommonWithStack(ItemStack item) {
|
||||||
|
GL11.glScaled(2, 2, 2);
|
||||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||||
if(item.getItemDamage() == BlockPileDevice.ITEM_META_LOADER) {
|
if(item.getItemDamage() == BlockPileDevice.ITEM_META_LOADER) {
|
||||||
bindTexture(ResourceManager.pile_loader_tex);
|
bindTexture(ResourceManager.pile_loader_tex);
|
||||||
|
|||||||
@ -29,7 +29,7 @@ public class RenderPileVent extends TileEntitySpecialRenderer {
|
|||||||
|
|
||||||
bindTexture(ResourceManager.pile_vent_tex);
|
bindTexture(ResourceManager.pile_vent_tex);
|
||||||
ResourceManager.pile_vent.renderPart("Pipe");
|
ResourceManager.pile_vent.renderPart("Pipe");
|
||||||
GL11.glRotated(rot, 0, -1, 0);
|
GL11.glRotated(rot, 0, 1, 0);
|
||||||
ResourceManager.pile_vent.renderPart("Fan");
|
ResourceManager.pile_vent.renderPart("Fan");
|
||||||
|
|
||||||
GL11.glShadeModel(GL11.GL_FLAT);
|
GL11.glShadeModel(GL11.GL_FLAT);
|
||||||
|
|||||||
@ -2,7 +2,6 @@ package com.hbm.tileentity.machine.pile;
|
|||||||
|
|
||||||
import com.hbm.blocks.ModBlocks;
|
import com.hbm.blocks.ModBlocks;
|
||||||
import com.hbm.blocks.machine.pile.BlockPile;
|
import com.hbm.blocks.machine.pile.BlockPile;
|
||||||
import com.hbm.tileentity.TileEntityTickingBase;
|
|
||||||
import com.hbm.tileentity.machine.pile.TileEntityPileCore.PileChannel;
|
import com.hbm.tileentity.machine.pile.TileEntityPileCore.PileChannel;
|
||||||
import com.hbm.util.Compat;
|
import com.hbm.util.Compat;
|
||||||
|
|
||||||
@ -12,7 +11,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
public class TileEntityPileControl extends TileEntityTickingBase implements IRORInteractive {
|
public class TileEntityPileControl extends TileEntityPileDeviceBase implements IRORInteractive {
|
||||||
|
|
||||||
public double syncLevel;
|
public double syncLevel;
|
||||||
public double level;
|
public double level;
|
||||||
@ -24,8 +23,6 @@ public class TileEntityPileControl extends TileEntityTickingBase implements IROR
|
|||||||
public static final double SPEED = 1D / 60D; // full traverse takes 3s
|
public static final double SPEED = 1D / 60D; // full traverse takes 3s
|
||||||
public boolean wasRedstone;
|
public boolean wasRedstone;
|
||||||
|
|
||||||
public int chanNum;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity() {
|
public void updateEntity() {
|
||||||
|
|
||||||
@ -53,7 +50,7 @@ public class TileEntityPileControl extends TileEntityTickingBase implements IROR
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(canMove) {
|
if(canMove && this.level != this.targetLevel) {
|
||||||
if(Math.abs(level - targetLevel) <= SPEED) {
|
if(Math.abs(level - targetLevel) <= SPEED) {
|
||||||
this.level = this.targetLevel;
|
this.level = this.targetLevel;
|
||||||
} else if(level < targetLevel) {
|
} else if(level < targetLevel) {
|
||||||
@ -63,7 +60,7 @@ public class TileEntityPileControl extends TileEntityTickingBase implements IROR
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() % 4 + 2);
|
ForgeDirection dir = this.getOrientation();
|
||||||
boolean redstone = worldObj.getIndirectPowerOutput(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ, dir.getOpposite().ordinal());
|
boolean redstone = worldObj.getIndirectPowerOutput(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ, dir.getOpposite().ordinal());
|
||||||
|
|
||||||
if(redstone && !wasRedstone) this.setTarget(1D);
|
if(redstone && !wasRedstone) this.setTarget(1D);
|
||||||
@ -90,7 +87,6 @@ public class TileEntityPileControl extends TileEntityTickingBase implements IROR
|
|||||||
public void serialize(ByteBuf buf) {
|
public void serialize(ByteBuf buf) {
|
||||||
super.serialize(buf);
|
super.serialize(buf);
|
||||||
buf.writeDouble(this.level);
|
buf.writeDouble(this.level);
|
||||||
buf.writeInt(this.chanNum);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -98,7 +94,6 @@ public class TileEntityPileControl extends TileEntityTickingBase implements IROR
|
|||||||
super.deserialize(buf);
|
super.deserialize(buf);
|
||||||
double lastSync = this.syncLevel;
|
double lastSync = this.syncLevel;
|
||||||
this.syncLevel = buf.readDouble();
|
this.syncLevel = buf.readDouble();
|
||||||
this.chanNum = buf.readInt();
|
|
||||||
|
|
||||||
if(this.syncLevel != lastSync) this.turnProgress = 2;
|
if(this.syncLevel != lastSync) this.turnProgress = 2;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import com.hbm.blocks.ModBlocks;
|
|||||||
import com.hbm.blocks.machine.MachinePWRController;
|
import com.hbm.blocks.machine.MachinePWRController;
|
||||||
import com.hbm.blocks.machine.pile.BlockPile;
|
import com.hbm.blocks.machine.pile.BlockPile;
|
||||||
import com.hbm.interfaces.NotableComments;
|
import com.hbm.interfaces.NotableComments;
|
||||||
|
import com.hbm.main.NTMSounds;
|
||||||
import com.hbm.packet.PacketDispatcher;
|
import com.hbm.packet.PacketDispatcher;
|
||||||
import com.hbm.packet.toclient.AuxParticlePacketNT;
|
import com.hbm.packet.toclient.AuxParticlePacketNT;
|
||||||
import com.hbm.tileentity.TileEntityTickingBase;
|
import com.hbm.tileentity.TileEntityTickingBase;
|
||||||
@ -144,6 +145,7 @@ public class TileEntityPileCore extends TileEntityTickingBase {
|
|||||||
int iZ = z + dir.offsetZ * j;
|
int iZ = z + dir.offsetZ * j;
|
||||||
worldObj.setBlockMetadataWithNotify(iX, iY, iZ, BlockPile.META_DUMMY, 3);
|
worldObj.setBlockMetadataWithNotify(iX, iY, iZ, BlockPile.META_DUMMY, 3);
|
||||||
}
|
}
|
||||||
|
worldObj.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, NTMSounds.VANILLA_PLINK, 1F, 0.75F);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -182,7 +184,8 @@ public class TileEntityPileCore extends TileEntityTickingBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
list.add(new PileChannel(x, y, z, dir, size, type));
|
list.add(new PileChannel(x, y, z, dir, size, type));
|
||||||
|
|
||||||
|
worldObj.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, NTMSounds.VANILLA_PLINK, 1F, 1.25F);
|
||||||
this.markChanged();
|
this.markChanged();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -0,0 +1,27 @@
|
|||||||
|
package com.hbm.tileentity.machine.pile;
|
||||||
|
|
||||||
|
import com.hbm.tileentity.TileEntityTickingBase;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
public abstract class TileEntityPileDeviceBase extends TileEntityTickingBase {
|
||||||
|
|
||||||
|
public int chanNum;
|
||||||
|
|
||||||
|
public ForgeDirection getOrientation() {
|
||||||
|
return ForgeDirection.getOrientation(this.getBlockMetadata() % 4 + 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void serialize(ByteBuf buf) {
|
||||||
|
super.serialize(buf);
|
||||||
|
buf.writeInt(this.chanNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deserialize(ByteBuf buf) {
|
||||||
|
super.deserialize(buf);
|
||||||
|
this.chanNum = buf.readInt();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,7 +1,156 @@
|
|||||||
package com.hbm.tileentity.machine.pile;
|
package com.hbm.tileentity.machine.pile;
|
||||||
|
|
||||||
|
import com.hbm.blocks.ModBlocks;
|
||||||
|
import com.hbm.blocks.machine.pile.BlockPile;
|
||||||
|
import com.hbm.main.NTMSounds;
|
||||||
|
import com.hbm.tileentity.machine.pile.TileEntityPileCore.PileChannel;
|
||||||
|
import com.hbm.util.Compat;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.inventory.ISidedInventory;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
public class TileEntityPileLoader extends TileEntity {
|
public class TileEntityPileLoader extends TileEntityPileDeviceBase implements ISidedInventory{
|
||||||
|
|
||||||
|
public double syncLevel;
|
||||||
|
public double level;
|
||||||
|
public double lastLevel;
|
||||||
|
|
||||||
|
public int turnProgress;
|
||||||
|
|
||||||
|
public static final double SPEED = 1D / 7D;
|
||||||
|
|
||||||
|
public boolean loading = false;
|
||||||
|
public int delay = 0;
|
||||||
|
public boolean hasRod = false;
|
||||||
|
public ItemStack stack;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateEntity() {
|
||||||
|
|
||||||
|
if(!worldObj.isRemote) {
|
||||||
|
|
||||||
|
this.hasRod = this.stack != null;
|
||||||
|
|
||||||
|
ForgeDirection dir = getOrientation();
|
||||||
|
|
||||||
|
int x = xCoord - dir.offsetX;
|
||||||
|
int y = yCoord;
|
||||||
|
int z = zCoord - dir.offsetZ;
|
||||||
|
|
||||||
|
if(worldObj.getBlock(x, y, z) == ModBlocks.pile_block && worldObj.getBlockMetadata(x, y, z) == BlockPile.META_FUEL_IN) {
|
||||||
|
TileEntity tile = Compat.getTileStandard(worldObj, x, y, z);
|
||||||
|
|
||||||
|
if(tile instanceof TileEntityPileBaseMK2) {
|
||||||
|
TileEntityPileBaseMK2 pile = (TileEntityPileBaseMK2) tile;
|
||||||
|
TileEntityPileCore core = pile.getCore();
|
||||||
|
|
||||||
|
if(core != null) {
|
||||||
|
PileChannel fuelChan = core.getFuelChannel(x, y, z);
|
||||||
|
|
||||||
|
if(fuelChan != null) {
|
||||||
|
this.chanNum = core.getFuelChannelNum(fuelChan);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.delay > 0) {
|
||||||
|
this.delay--;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if(loading) {
|
||||||
|
|
||||||
|
if(this.level == 0) worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, NTMSounds.GUN_BOLT_OPEN, this.getVolume(1F), 1F);
|
||||||
|
|
||||||
|
this.level += SPEED;
|
||||||
|
if(this.level >= 1D) {
|
||||||
|
this.level = 1D;
|
||||||
|
this.loading = false;
|
||||||
|
this.delay = 5;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if(this.level == 1) {
|
||||||
|
worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, NTMSounds.GUN_BOLT_OPEN, this.getVolume(1F), 0.75F);
|
||||||
|
this.setInventorySlotContents(0, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.level > 0D) {
|
||||||
|
this.level -= SPEED;
|
||||||
|
if(this.level < 0D) this.level = 0D;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.networkPackNT(35);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
this.lastLevel = this.level;
|
||||||
|
|
||||||
|
if(this.turnProgress > 0) {
|
||||||
|
this.level = this.level + ((this.syncLevel - this.level) / (double) this.turnProgress);
|
||||||
|
--this.turnProgress;
|
||||||
|
} else {
|
||||||
|
this.level = this.syncLevel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void serialize(ByteBuf buf) {
|
||||||
|
super.serialize(buf);
|
||||||
|
buf.writeDouble(this.level);
|
||||||
|
buf.writeBoolean(this.hasRod);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deserialize(ByteBuf buf) {
|
||||||
|
super.deserialize(buf);
|
||||||
|
double lastSync = this.syncLevel;
|
||||||
|
this.syncLevel = buf.readDouble();
|
||||||
|
this.hasRod = buf.readBoolean();
|
||||||
|
|
||||||
|
if(this.syncLevel != lastSync) this.turnProgress = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isItemLoadable(ItemStack stack) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack decrStackSize(int slot, int amount) {
|
||||||
|
if(amount == 1 && this.stack != null) {
|
||||||
|
ItemStack ret = stack.copy();
|
||||||
|
this.setInventorySlotContents(0, null);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||||
|
this.stack = stack;
|
||||||
|
this.markDirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public int getSizeInventory() { return 1; }
|
||||||
|
@Override public ItemStack getStackInSlot(int slot) { return stack; }
|
||||||
|
@Override public ItemStack getStackInSlotOnClosing(int slot) { return null; }
|
||||||
|
@Override public String getInventoryName() { return "NULL"; }
|
||||||
|
@Override public boolean hasCustomInventoryName() { return false; }
|
||||||
|
@Override public int getInventoryStackLimit() { return 1; }
|
||||||
|
|
||||||
|
@Override public boolean isUseableByPlayer(EntityPlayer player) { return false; }
|
||||||
|
@Override public void openInventory() { }
|
||||||
|
@Override public void closeInventory() { }
|
||||||
|
|
||||||
|
@Override public int[] getAccessibleSlotsFromSide(int side) { return new int[] {0}; }
|
||||||
|
@Override public boolean isItemValidForSlot(int slot, ItemStack stack) { return isItemLoadable(stack); }
|
||||||
|
@Override public boolean canInsertItem(int slot, ItemStack stack, int side) { return isItemLoadable(stack); }
|
||||||
|
@Override public boolean canExtractItem(int slot, ItemStack stack, int side) { return false; }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,6 @@ import com.hbm.blocks.machine.pile.BlockPile;
|
|||||||
import com.hbm.inventory.fluid.FluidType;
|
import com.hbm.inventory.fluid.FluidType;
|
||||||
import com.hbm.inventory.fluid.Fluids;
|
import com.hbm.inventory.fluid.Fluids;
|
||||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||||
import com.hbm.tileentity.TileEntityTickingBase;
|
|
||||||
import com.hbm.tileentity.machine.pile.TileEntityPileCore.PileChannel;
|
import com.hbm.tileentity.machine.pile.TileEntityPileCore.PileChannel;
|
||||||
import com.hbm.util.BobMathUtil;
|
import com.hbm.util.BobMathUtil;
|
||||||
import com.hbm.util.Compat;
|
import com.hbm.util.Compat;
|
||||||
@ -15,7 +14,7 @@ import io.netty.buffer.ByteBuf;
|
|||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
public class TileEntityPileVent extends TileEntityTickingBase implements IFluidStandardReceiverMK2 {
|
public class TileEntityPileVent extends TileEntityPileDeviceBase implements IFluidStandardReceiverMK2 {
|
||||||
|
|
||||||
public FluidTank compair;
|
public FluidTank compair;
|
||||||
public boolean isActive = false;
|
public boolean isActive = false;
|
||||||
@ -23,8 +22,6 @@ public class TileEntityPileVent extends TileEntityTickingBase implements IFluidS
|
|||||||
public float fan;
|
public float fan;
|
||||||
public float lastFan;
|
public float lastFan;
|
||||||
|
|
||||||
public int chanNum;
|
|
||||||
|
|
||||||
public TileEntityPileVent() {
|
public TileEntityPileVent() {
|
||||||
this.compair = new FluidTank(Fluids.AIR, 4_000).withPressure(1);
|
this.compair = new FluidTank(Fluids.AIR, 4_000).withPressure(1);
|
||||||
}
|
}
|
||||||
@ -49,28 +46,26 @@ public class TileEntityPileVent extends TileEntityTickingBase implements IFluidS
|
|||||||
|
|
||||||
this.isActive = false;
|
this.isActive = false;
|
||||||
|
|
||||||
if(this.compair.getFill() > 0) {
|
int x = xCoord - dir.offsetX;
|
||||||
int x = xCoord - dir.offsetX;
|
int y = yCoord;
|
||||||
int y = yCoord;
|
int z = zCoord - dir.offsetZ;
|
||||||
int z = zCoord - dir.offsetZ;
|
|
||||||
|
if(worldObj.getBlock(x, y, z) == ModBlocks.pile_block && worldObj.getBlockMetadata(x, y, z) == BlockPile.META_AIR_IN) {
|
||||||
if(worldObj.getBlock(x, y, z) == ModBlocks.pile_block && worldObj.getBlockMetadata(x, y, z) == BlockPile.META_AIR_IN) {
|
TileEntity tile = Compat.getTileStandard(worldObj, x, y, z);
|
||||||
TileEntity tile = Compat.getTileStandard(worldObj, x, y, z);
|
|
||||||
|
if(tile instanceof TileEntityPileBaseMK2) {
|
||||||
if(tile instanceof TileEntityPileBaseMK2) {
|
TileEntityPileBaseMK2 pile = (TileEntityPileBaseMK2) tile;
|
||||||
TileEntityPileBaseMK2 pile = (TileEntityPileBaseMK2) tile;
|
TileEntityPileCore core = pile.getCore();
|
||||||
TileEntityPileCore core = pile.getCore();
|
|
||||||
|
if(core != null) {
|
||||||
if(core != null) {
|
PileChannel ventChan = core.getVentilationChannel(x, y, z);
|
||||||
PileChannel ventChan = core.getVentilationChannel(x, y, z);
|
|
||||||
|
if(ventChan != null) {
|
||||||
if(ventChan != null) {
|
this.chanNum = core.getVentilationChannelNum(ventChan);
|
||||||
this.isActive = true;
|
int toFill = BobMathUtil.min(compair.getFill(), 1_000 - ventChan.air);
|
||||||
this.chanNum = core.getVentilationChannelNum(ventChan);
|
ventChan.air += toFill;
|
||||||
int toFill = BobMathUtil.min(compair.getFill(), 1_000 - ventChan.air);
|
this.compair.setFill(this.compair.getFill() - toFill);
|
||||||
ventChan.air += toFill;
|
this.isActive = toFill > 0;
|
||||||
this.compair.setFill(this.compair.getFill() - toFill);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -81,7 +76,10 @@ public class TileEntityPileVent extends TileEntityTickingBase implements IFluidS
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
this.lastFan = fan;
|
this.lastFan = fan;
|
||||||
if(this.isActive) this.fan += 45;
|
if(this.isActive) {
|
||||||
|
this.fan += 45;
|
||||||
|
if(worldObj.rand.nextInt(20) == 0) worldObj.spawnParticle("cloud", xCoord + 0.5, yCoord + 1, zCoord + 0.5, 0, 0.05, 0);
|
||||||
|
}
|
||||||
|
|
||||||
if(this.fan >= 360) {
|
if(this.fan >= 360) {
|
||||||
this.lastFan -= 360;
|
this.lastFan -= 360;
|
||||||
@ -89,22 +87,16 @@ public class TileEntityPileVent extends TileEntityTickingBase implements IFluidS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ForgeDirection getOrientation() {
|
|
||||||
return ForgeDirection.getOrientation(this.getBlockMetadata() % 4 + 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf buf) {
|
public void serialize(ByteBuf buf) {
|
||||||
super.serialize(buf);
|
super.serialize(buf);
|
||||||
buf.writeBoolean(this.isActive);
|
buf.writeBoolean(this.isActive);
|
||||||
buf.writeInt(this.chanNum);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deserialize(ByteBuf buf) {
|
public void deserialize(ByteBuf buf) {
|
||||||
super.deserialize(buf);
|
super.deserialize(buf);
|
||||||
this.isActive = buf.readBoolean();
|
this.isActive = buf.readBoolean();
|
||||||
this.chanNum = buf.readInt();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5979,6 +5979,11 @@ tile.pa_source.name=Particle Source
|
|||||||
tile.pa_source.desc=Requires cooling!$Uses two items to create a particle.
|
tile.pa_source.desc=Requires cooling!$Uses two items to create a particle.
|
||||||
tile.part_emitter.name=Deco Particle Emitter
|
tile.part_emitter.name=Deco Particle Emitter
|
||||||
tile.pedestal.name=Pedestal
|
tile.pedestal.name=Pedestal
|
||||||
|
tile.pile_block.name=Chicago Pile
|
||||||
|
tile.pile_brick.name=Chicago Pile Graphite Bricks
|
||||||
|
tile.pile_device.control.name=Chicago Pile Control Rod
|
||||||
|
tile.pile_device.loader.name=Chicago Pile Fuel Loader
|
||||||
|
tile.pile_device.vent.name=Chicago Pile Vent
|
||||||
tile.pink_barrel.name=Kerosene Barrel
|
tile.pink_barrel.name=Kerosene Barrel
|
||||||
tile.pink_log.name=Pink Log
|
tile.pink_log.name=Pink Log
|
||||||
tile.pink_planks.name=Pink Wood Planks
|
tile.pink_planks.name=Pink Wood Planks
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user