mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
ow my bals
This commit is contained in:
parent
7861b4e20f
commit
d71b0bd2c5
@ -1240,6 +1240,7 @@ public class ModBlocks {
|
|||||||
public static Block wand_air;
|
public static Block wand_air;
|
||||||
public static Block wand_loot;
|
public static Block wand_loot;
|
||||||
public static Block wand_jigsaw;
|
public static Block wand_jigsaw;
|
||||||
|
public static Block wand_tandem;
|
||||||
|
|
||||||
public static Material materialGas = new MaterialGas();
|
public static Material materialGas = new MaterialGas();
|
||||||
|
|
||||||
@ -2390,6 +2391,7 @@ public class ModBlocks {
|
|||||||
wand_air = new BlockWand(Blocks.air).setBlockName("wand_air").setBlockTextureName(RefStrings.MODID + ":wand_air");
|
wand_air = new BlockWand(Blocks.air).setBlockName("wand_air").setBlockTextureName(RefStrings.MODID + ":wand_air");
|
||||||
wand_loot = new BlockWandLoot().setBlockName("wand_loot").setBlockTextureName(RefStrings.MODID + ":wand_loot");
|
wand_loot = new BlockWandLoot().setBlockName("wand_loot").setBlockTextureName(RefStrings.MODID + ":wand_loot");
|
||||||
wand_jigsaw = new BlockWandJigsaw().setBlockName("wand_jigsaw").setBlockTextureName(RefStrings.MODID + ":wand_jigsaw");
|
wand_jigsaw = new BlockWandJigsaw().setBlockName("wand_jigsaw").setBlockTextureName(RefStrings.MODID + ":wand_jigsaw");
|
||||||
|
wand_tandem = new BlockWandTandem().setBlockName("wand_tandem").setBlockTextureName(RefStrings.MODID + ":wand_tandem");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerBlock() {
|
private static void registerBlock() {
|
||||||
@ -3534,6 +3536,7 @@ public class ModBlocks {
|
|||||||
register(wand_air);
|
register(wand_air);
|
||||||
register(wand_loot);
|
register(wand_loot);
|
||||||
register(wand_jigsaw);
|
register(wand_jigsaw);
|
||||||
|
register(wand_tandem);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void register(Block b) {
|
private static void register(Block b) {
|
||||||
|
|||||||
@ -399,7 +399,6 @@ public class BlockWandJigsaw extends BlockContainer implements IBlockSideRotatio
|
|||||||
textPlacementPriority.mouseClicked(mouseX, mouseY, mouseButton);
|
textPlacementPriority.mouseClicked(mouseX, mouseY, mouseButton);
|
||||||
|
|
||||||
if(jointToggle.mousePressed(mc, mouseX, mouseY)) {
|
if(jointToggle.mousePressed(mc, mouseX, mouseY)) {
|
||||||
System.out.println("displayString: " + jointToggle.displayString);
|
|
||||||
jointToggle.displayString = jointToggle.displayString == "Rollable" ? "Aligned" : "Rollable";
|
jointToggle.displayString = jointToggle.displayString == "Rollable" ? "Aligned" : "Rollable";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
384
src/main/java/com/hbm/blocks/generic/BlockWandTandem.java
Normal file
384
src/main/java/com/hbm/blocks/generic/BlockWandTandem.java
Normal file
@ -0,0 +1,384 @@
|
|||||||
|
package com.hbm.blocks.generic;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
|
import com.hbm.blocks.IBlockSideRotation;
|
||||||
|
import com.hbm.blocks.ILookOverlay;
|
||||||
|
import com.hbm.blocks.ModBlocks;
|
||||||
|
import com.hbm.interfaces.IControlReceiver;
|
||||||
|
import com.hbm.items.ModItems;
|
||||||
|
import com.hbm.lib.RefStrings;
|
||||||
|
import com.hbm.main.MainRegistry;
|
||||||
|
import com.hbm.packet.PacketDispatcher;
|
||||||
|
import com.hbm.packet.toserver.NBTControlPacket;
|
||||||
|
import com.hbm.tileentity.IGUIProvider;
|
||||||
|
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||||
|
import com.hbm.util.BufferUtil;
|
||||||
|
import com.hbm.util.I18nUtil;
|
||||||
|
import com.hbm.world.gen.INBTTransformable;
|
||||||
|
import com.hbm.world.gen.NBTStructure;
|
||||||
|
import com.hbm.world.gen.NBTStructure.JigsawPiece;
|
||||||
|
import com.hbm.world.gen.NBTStructure.JigsawPool;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||||
|
import cpw.mods.fml.common.registry.GameRegistry;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockContainer;
|
||||||
|
import net.minecraft.block.BlockPistonBase;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
import net.minecraft.client.gui.GuiTextField;
|
||||||
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.init.Items;
|
||||||
|
import net.minecraft.inventory.Container;
|
||||||
|
import net.minecraft.item.ItemBlock;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.EnumChatFormatting;
|
||||||
|
import net.minecraft.util.IIcon;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* You're familiar with Billy Mitchell, World Video Game Champion? He could probably do it.
|
||||||
|
* So I gotta find a way to harness his power. And I think I've found a way.
|
||||||
|
*
|
||||||
|
* THAT'S RIGHT, WE'RE GONNA CHEAT.
|
||||||
|
*
|
||||||
|
* NBTStructures have the inherent flaws of the vanilla structure system: Structures are composed
|
||||||
|
* before terrain gen even kicks in, placement order of components are arbitrary and certain
|
||||||
|
* connected parts will fall apart due to unexpected variance in the terrain. Not good.
|
||||||
|
* The solution: Simply delay generation of parts using a tile entity that checks if the chunks
|
||||||
|
* in front of it are loaded, and then places a random part from the chosen pool. When this happens,
|
||||||
|
* the player is usually still far far away so they'll be none the wiser. Chunk load checks help
|
||||||
|
* prevent forced chunk loading and all the lag that comes with that.
|
||||||
|
*
|
||||||
|
* The system is named after tandem shaped charges: Make a hole with the first charge, then deliver
|
||||||
|
* the actual payload.
|
||||||
|
*
|
||||||
|
* @author hbm
|
||||||
|
*/
|
||||||
|
public class BlockWandTandem extends BlockContainer implements IBlockSideRotation, INBTTransformable, IGUIProvider, ILookOverlay {
|
||||||
|
|
||||||
|
private IIcon iconTop;
|
||||||
|
private IIcon iconSide;
|
||||||
|
private IIcon iconBack;
|
||||||
|
|
||||||
|
public BlockWandTandem() {
|
||||||
|
super(Material.iron);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity createNewTileEntity(World world, int meta) {
|
||||||
|
return new TileEntityWandTandem();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
|
||||||
|
int l = BlockPistonBase.determineOrientation(world, x, y, z, player);
|
||||||
|
world.setBlockMetadataWithNotify(x, y, z, l, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||||
|
this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":wand_tandem");
|
||||||
|
this.iconTop = iconRegister.registerIcon(RefStrings.MODID + ":wand_tandem_top");
|
||||||
|
this.iconSide = iconRegister.registerIcon(RefStrings.MODID + ":wand_tandem_side");
|
||||||
|
this.iconBack = iconRegister.registerIcon(RefStrings.MODID + ":wand_tandem_back");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IIcon getIcon(int side, int meta) {
|
||||||
|
if(side == meta) return blockIcon;
|
||||||
|
if(IBlockSideRotation.isOpposite(side, meta)) return iconBack;
|
||||||
|
if(side <= 1) return iconTop;
|
||||||
|
if(side > 3 && meta <= 1) return iconTop;
|
||||||
|
return iconSide;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRotationFromSide(IBlockAccess world, int x, int y, int z, int side) {
|
||||||
|
if(side == 0) return IBlockSideRotation.topToBottom(getRotationFromSide(world, x, y, z, 1));
|
||||||
|
|
||||||
|
int meta = world.getBlockMetadata(x, y, z);
|
||||||
|
if(side == meta || IBlockSideRotation.isOpposite(side, meta)) return 0;
|
||||||
|
|
||||||
|
// downwards facing has no changes, upwards flips anything not handled already
|
||||||
|
if(meta == 0) return 0;
|
||||||
|
if(meta == 1) return 3;
|
||||||
|
|
||||||
|
// top (and bottom) is rotated fairly normally
|
||||||
|
if(side == 1) {
|
||||||
|
switch(meta) {
|
||||||
|
case 2: return 3;
|
||||||
|
case 3: return 0;
|
||||||
|
case 4: return 1;
|
||||||
|
case 5: return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// you know what I aint explaining further, it's a fucking mess here
|
||||||
|
if(meta == 2) return side == 4 ? 2 : 1;
|
||||||
|
if(meta == 3) return side == 4 ? 1 : 2;
|
||||||
|
if(meta == 4) return side == 2 ? 1 : 2;
|
||||||
|
if(meta == 5) return side == 2 ? 2 : 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRenderType() {
|
||||||
|
return IBlockSideRotation.getRenderType();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int transformMeta(int meta, int coordBaseMode) {
|
||||||
|
return INBTTransformable.transformMetaDeco(meta, coordBaseMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||||
|
TileEntity te = world.getTileEntity(x, y, z);
|
||||||
|
|
||||||
|
if(!(te instanceof TileEntityWandTandem)) return false;
|
||||||
|
|
||||||
|
TileEntityWandTandem jigsaw = (TileEntityWandTandem) te;
|
||||||
|
|
||||||
|
if(player.getHeldItem() != null && player.getHeldItem().getItem() == Items.paper) {
|
||||||
|
TileEntityWandTandem.copyMode = true;
|
||||||
|
if(!player.getHeldItem().hasTagCompound()) {
|
||||||
|
player.getHeldItem().stackTagCompound = new NBTTagCompound();
|
||||||
|
jigsaw.writeToNBT(player.getHeldItem().stackTagCompound);
|
||||||
|
} else {
|
||||||
|
jigsaw.readFromNBT(player.getHeldItem().stackTagCompound);
|
||||||
|
jigsaw.markDirty();
|
||||||
|
}
|
||||||
|
TileEntityWandTandem.copyMode = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!player.isSneaking()) {
|
||||||
|
Block block = getBlock(world, player.getHeldItem());
|
||||||
|
if(block == ModBlocks.wand_air) block = Blocks.air;
|
||||||
|
|
||||||
|
if(block != null && block != ModBlocks.wand_jigsaw && block != ModBlocks.wand_loot) {
|
||||||
|
jigsaw.replaceBlock = block;
|
||||||
|
jigsaw.replaceMeta = player.getHeldItem().getItemDamage();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(player.getHeldItem() != null && player.getHeldItem().getItem() == ModItems.wand_s) return false;
|
||||||
|
|
||||||
|
if(world.isRemote) FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Block getBlock(World world, ItemStack stack) {
|
||||||
|
if(stack == null) return null;
|
||||||
|
if(!(stack.getItem() instanceof ItemBlock)) return null;
|
||||||
|
|
||||||
|
return ((ItemBlock) stack.getItem()).field_150939_a;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||||
|
return new GuiWandTandem((TileEntityWandTandem) world.getTileEntity(x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void printHook(Pre event, World world, int x, int y, int z) {
|
||||||
|
TileEntity te = world.getTileEntity(x, y, z);
|
||||||
|
if(!(te instanceof TileEntityWandTandem)) return;
|
||||||
|
TileEntityWandTandem jigsaw = (TileEntityWandTandem) te;
|
||||||
|
|
||||||
|
List<String> text = new ArrayList<String>();
|
||||||
|
|
||||||
|
text.add(EnumChatFormatting.GRAY + "Target name: " + EnumChatFormatting.RESET + jigsaw.target);
|
||||||
|
text.add(EnumChatFormatting.GRAY + "Turns into: " + EnumChatFormatting.RESET + GameRegistry.findUniqueIdentifierFor(jigsaw.replaceBlock).toString());
|
||||||
|
text.add(EnumChatFormatting.GRAY + " with meta: " + EnumChatFormatting.RESET + jigsaw.replaceMeta);
|
||||||
|
text.add(EnumChatFormatting.GRAY + "Joint type: " + EnumChatFormatting.RESET + (jigsaw.isRollable ? "Rollable" : "Aligned"));
|
||||||
|
|
||||||
|
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static class TileEntityWandTandem extends TileEntityLoadedBase implements IControlReceiver {
|
||||||
|
|
||||||
|
private String target = "default";
|
||||||
|
private Block replaceBlock = Blocks.air;
|
||||||
|
private int replaceMeta = 0;
|
||||||
|
private boolean isRollable = true; // sets joint type, rollable joints can be placed in any orientation for vertical jigsaw connections
|
||||||
|
public boolean isArmed = false;
|
||||||
|
public static boolean copyMode = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateEntity() {
|
||||||
|
if(!worldObj.isRemote) {
|
||||||
|
|
||||||
|
tryGenerate();
|
||||||
|
networkPackNT(15);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void tryGenerate() {
|
||||||
|
if(!this.isArmed || target == null || target.isEmpty()) return;
|
||||||
|
JigsawPool pool = NBTStructure.tandemSharedJiggies.get(target);
|
||||||
|
if(pool == null) return;
|
||||||
|
JigsawPiece nextPiece = pool.get(worldObj.rand);
|
||||||
|
if(nextPiece == null) return;
|
||||||
|
|
||||||
|
//death
|
||||||
|
/*int ox = nextPiece.structure.rotateX(toConnection.pos.x, toConnection.pos.z, nextCoordBase);
|
||||||
|
int oy = toConnection.pos.y;
|
||||||
|
int oz = nextPiece.structure.rotateZ(toConnection.pos.x, toConnection.pos.z, nextCoordBase);
|
||||||
|
nextPiece.structure.build(world, x, y, z, coordBaseMode);*/
|
||||||
|
|
||||||
|
worldObj.setBlock(xCoord, yCoord, zCoord, replaceBlock, replaceMeta, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void serialize(ByteBuf buf) {
|
||||||
|
BufferUtil.writeString(buf, target);
|
||||||
|
buf.writeInt(Block.getIdFromBlock(replaceBlock));
|
||||||
|
buf.writeInt(replaceMeta);
|
||||||
|
buf.writeBoolean(isRollable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deserialize(ByteBuf buf) {
|
||||||
|
target = BufferUtil.readString(buf);
|
||||||
|
replaceBlock = Block.getBlockById(buf.readInt());
|
||||||
|
replaceMeta = buf.readInt();
|
||||||
|
isRollable = buf.readBoolean();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToNBT(NBTTagCompound nbt) {
|
||||||
|
if(!copyMode) {
|
||||||
|
super.writeToNBT(nbt);
|
||||||
|
nbt.setInteger("direction", this.getBlockMetadata());
|
||||||
|
nbt.setBoolean("isArmed", isArmed);
|
||||||
|
}
|
||||||
|
|
||||||
|
nbt.setString("target", target);
|
||||||
|
nbt.setString("block", GameRegistry.findUniqueIdentifierFor(replaceBlock).toString());
|
||||||
|
nbt.setInteger("meta", replaceMeta);
|
||||||
|
nbt.setBoolean("roll", isRollable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readFromNBT(NBTTagCompound nbt) {
|
||||||
|
if(!copyMode) {
|
||||||
|
super.readFromNBT(nbt);
|
||||||
|
isArmed = nbt.getBoolean("isArmed");
|
||||||
|
}
|
||||||
|
|
||||||
|
target = nbt.getString("target");
|
||||||
|
replaceBlock = Block.getBlockFromName(nbt.getString("block"));
|
||||||
|
replaceMeta = nbt.getInteger("meta");
|
||||||
|
isRollable = nbt.getBoolean("roll");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(EntityPlayer player) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void receiveControl(NBTTagCompound nbt) {
|
||||||
|
readFromNBT(nbt);
|
||||||
|
markDirty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class GuiWandTandem extends GuiScreen {
|
||||||
|
|
||||||
|
private final TileEntityWandTandem jigsaw;
|
||||||
|
|
||||||
|
private GuiTextField textTarget;
|
||||||
|
|
||||||
|
private GuiButton jointToggle;
|
||||||
|
|
||||||
|
public GuiWandTandem(TileEntityWandTandem jigsaw) {
|
||||||
|
this.jigsaw = jigsaw;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initGui() {
|
||||||
|
Keyboard.enableRepeatEvents(true);
|
||||||
|
|
||||||
|
textTarget = new GuiTextField(fontRendererObj, this.width / 2 + 10, 100, 140, 20);
|
||||||
|
textTarget.setText(jigsaw.target);
|
||||||
|
|
||||||
|
jointToggle = new GuiButton(0, this.width / 2 + 60, 150, 90, 20, jigsaw.isRollable ? "Rollable" : "Aligned");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||||
|
drawDefaultBackground();
|
||||||
|
|
||||||
|
drawString(fontRendererObj, "Target name:", this.width / 2 + 10, 87, 0xA0A0A0);
|
||||||
|
textTarget.drawTextBox();
|
||||||
|
|
||||||
|
drawString(fontRendererObj, "Joint type:", this.width / 2 + 60, 137, 0xA0A0A0);
|
||||||
|
jointToggle.drawButton(mc, mouseX, mouseY);
|
||||||
|
|
||||||
|
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onGuiClosed() {
|
||||||
|
Keyboard.enableRepeatEvents(false);
|
||||||
|
|
||||||
|
NBTTagCompound data = new NBTTagCompound();
|
||||||
|
jigsaw.writeToNBT(data);
|
||||||
|
|
||||||
|
data.setString("target", textTarget.getText());
|
||||||
|
data.setBoolean("roll", jointToggle.displayString == "Rollable");
|
||||||
|
|
||||||
|
PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, jigsaw.xCoord, jigsaw.yCoord, jigsaw.zCoord));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void keyTyped(char typedChar, int keyCode) {
|
||||||
|
super.keyTyped(typedChar, keyCode);
|
||||||
|
textTarget.textboxKeyTyped(typedChar, keyCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||||
|
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||||
|
textTarget.mouseClicked(mouseX, mouseY, mouseButton);
|
||||||
|
|
||||||
|
if(jointToggle.mousePressed(mc, mouseX, mouseY)) {
|
||||||
|
jointToggle.displayString = jointToggle.displayString == "Rollable" ? "Aligned" : "Rollable";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public boolean doesGuiPauseGame() { return false; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -41,10 +41,6 @@ public class ItemWandD extends Item {
|
|||||||
|
|
||||||
int y = world.getHeightValue(pos.blockX, pos.blockZ);
|
int y = world.getHeightValue(pos.blockX, pos.blockZ);
|
||||||
|
|
||||||
NTMWorldGenerator.TRENCH.canSpawn = biome -> { return true; };
|
|
||||||
NBTStructure.Start start = new NBTStructure.Start(world, world.rand, NTMWorldGenerator.TRENCH, pos.blockX >> 4, pos.blockZ >> 4);
|
|
||||||
start.generateStructure(world, world.rand, new StructureBoundingBox(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE));
|
|
||||||
|
|
||||||
/*ExplosionVNT vnt = new ExplosionVNT(world, pos.hitVec.xCoord, pos.hitVec.yCoord, pos.hitVec.zCoord, 7);
|
/*ExplosionVNT vnt = new ExplosionVNT(world, pos.hitVec.xCoord, pos.hitVec.yCoord, pos.hitVec.zCoord, 7);
|
||||||
vnt.setBlockAllocator(new BlockAllocatorBulkie(60));
|
vnt.setBlockAllocator(new BlockAllocatorBulkie(60));
|
||||||
vnt.setBlockProcessor(new BlockProcessorStandard().withBlockEffect(new BlockMutatorBulkie(ModBlocks.block_slag)).setNoDrop());
|
vnt.setBlockProcessor(new BlockProcessorStandard().withBlockEffect(new BlockMutatorBulkie(ModBlocks.block_slag)).setNoDrop());
|
||||||
|
|||||||
@ -19,6 +19,7 @@ import com.hbm.blocks.generic.BlockSnowglobe.TileEntitySnowglobe;
|
|||||||
import com.hbm.blocks.generic.BlockSupplyCrate.TileEntitySupplyCrate;
|
import com.hbm.blocks.generic.BlockSupplyCrate.TileEntitySupplyCrate;
|
||||||
import com.hbm.blocks.generic.BlockWandJigsaw.TileEntityWandJigsaw;
|
import com.hbm.blocks.generic.BlockWandJigsaw.TileEntityWandJigsaw;
|
||||||
import com.hbm.blocks.generic.BlockWandLoot.TileEntityWandLoot;
|
import com.hbm.blocks.generic.BlockWandLoot.TileEntityWandLoot;
|
||||||
|
import com.hbm.blocks.generic.BlockWandTandem.TileEntityWandTandem;
|
||||||
import com.hbm.blocks.generic.DungeonSpawner.TileEntityDungeonSpawner;
|
import com.hbm.blocks.generic.DungeonSpawner.TileEntityDungeonSpawner;
|
||||||
import com.hbm.blocks.generic.PartEmitter.TileEntityPartEmitter;
|
import com.hbm.blocks.generic.PartEmitter.TileEntityPartEmitter;
|
||||||
import com.hbm.blocks.machine.BlockICF.TileEntityBlockICF;
|
import com.hbm.blocks.machine.BlockICF.TileEntityBlockICF;
|
||||||
@ -242,6 +243,7 @@ public class TileMappings {
|
|||||||
|
|
||||||
put(TileEntityWandLoot.class, "tileentity_wand_loot");
|
put(TileEntityWandLoot.class, "tileentity_wand_loot");
|
||||||
put(TileEntityWandJigsaw.class, "tileentity_wand_jigsaw");
|
put(TileEntityWandJigsaw.class, "tileentity_wand_jigsaw");
|
||||||
|
put(TileEntityWandTandem.class, "tileentity_wand_tandem");
|
||||||
|
|
||||||
putNetwork();
|
putNetwork();
|
||||||
putBombs();
|
putBombs();
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import java.util.function.Predicate;
|
|||||||
|
|
||||||
import com.hbm.blocks.ModBlocks;
|
import com.hbm.blocks.ModBlocks;
|
||||||
import com.hbm.blocks.generic.BlockWand;
|
import com.hbm.blocks.generic.BlockWand;
|
||||||
|
import com.hbm.blocks.generic.BlockWandTandem.TileEntityWandTandem;
|
||||||
import com.hbm.config.GeneralConfig;
|
import com.hbm.config.GeneralConfig;
|
||||||
import com.hbm.config.StructureConfig;
|
import com.hbm.config.StructureConfig;
|
||||||
import com.hbm.handler.ThreeInts;
|
import com.hbm.handler.ThreeInts;
|
||||||
@ -58,6 +59,11 @@ public class NBTStructure {
|
|||||||
// serialization data
|
// serialization data
|
||||||
protected static Map<String, JigsawPiece> jigsawMap = new HashMap<>();
|
protected static Map<String, JigsawPiece> jigsawMap = new HashMap<>();
|
||||||
|
|
||||||
|
// getting jiggy with it
|
||||||
|
// since TANDEM blocks run after structure gen and therefore have no
|
||||||
|
// reference to the structure itself, we just make the pools publically accessible
|
||||||
|
public static HashMap<String, JigsawPool> tandemSharedJiggies = new HashMap();
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private boolean isLoaded;
|
private boolean isLoaded;
|
||||||
@ -101,6 +107,10 @@ public class NBTStructure {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void getJiggyWithIt(String jingle, JigsawPool pringles) {
|
||||||
|
tandemSharedJiggies.put(jingle, pringles);
|
||||||
|
}
|
||||||
|
|
||||||
// Add a chance for nothing to spawn at a given valid spawn location
|
// Add a chance for nothing to spawn at a given valid spawn location
|
||||||
public static void registerNullWeight(int dimensionId, int weight) {
|
public static void registerNullWeight(int dimensionId, int weight) {
|
||||||
registerNullWeight(dimensionId, weight, null);
|
registerNullWeight(dimensionId, weight, null);
|
||||||
@ -410,6 +420,10 @@ public class NBTStructure {
|
|||||||
((INBTTileEntityTransformable) te).transformTE(world, coordBaseMode);
|
((INBTTileEntityTransformable) te).transformTE(world, coordBaseMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(te instanceof TileEntityWandTandem) {
|
||||||
|
((TileEntityWandTandem) te).isArmed = true;
|
||||||
|
}
|
||||||
|
|
||||||
return te;
|
return te;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,6 @@ import java.util.Random;
|
|||||||
|
|
||||||
import com.hbm.blocks.ModBlocks;
|
import com.hbm.blocks.ModBlocks;
|
||||||
import com.hbm.config.StructureConfig;
|
import com.hbm.config.StructureConfig;
|
||||||
import com.hbm.lib.RefStrings;
|
|
||||||
import com.hbm.main.StructureManager;
|
import com.hbm.main.StructureManager;
|
||||||
import com.hbm.world.biome.BiomeGenNoMansLand;
|
import com.hbm.world.biome.BiomeGenNoMansLand;
|
||||||
import com.hbm.world.gen.NBTStructure.JigsawPiece;
|
import com.hbm.world.gen.NBTStructure.JigsawPiece;
|
||||||
@ -23,7 +22,6 @@ import com.hbm.world.gen.component.Component.SupplyCrates;
|
|||||||
import cpw.mods.fml.common.IWorldGenerator;
|
import cpw.mods.fml.common.IWorldGenerator;
|
||||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.biome.BiomeGenBase;
|
import net.minecraft.world.biome.BiomeGenBase;
|
||||||
import net.minecraft.world.chunk.IChunkProvider;
|
import net.minecraft.world.chunk.IChunkProvider;
|
||||||
@ -37,59 +35,6 @@ public class NTMWorldGenerator implements IWorldGenerator {
|
|||||||
|
|
||||||
boolean regTest = false;
|
boolean regTest = false;
|
||||||
|
|
||||||
public static final NBTStructure trench_straight = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/trench/straight.nbt"));
|
|
||||||
public static final NBTStructure trench_straight_dirt = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/trench/straight_dirt.nbt"));
|
|
||||||
public static final NBTStructure trench_straight_bridge = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/trench/straight_bridge.nbt"));
|
|
||||||
public static final NBTStructure trench_straight_stairs = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/trench/straight_stairs.nbt"));
|
|
||||||
public static final NBTStructure trench_straight_door_left = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/trench/straight_door_left.nbt"));
|
|
||||||
public static final NBTStructure trench_t_outer = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/trench/t_outer.nbt"));
|
|
||||||
public static final NBTStructure trench_t_inner = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/trench/t_inner.nbt"));
|
|
||||||
public static final NBTStructure trench_s_left = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/trench/s_left.nbt"));
|
|
||||||
public static final NBTStructure trench_s_right = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/trench/s_right.nbt"));
|
|
||||||
public static final NBTStructure trench_end_left = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/trench/end_left.nbt"));
|
|
||||||
public static final NBTStructure trench_end_right = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/trench/end_right.nbt"));
|
|
||||||
public static final NBTStructure trench_cross = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/trench/cross.nbt"));
|
|
||||||
public static final NBTStructure trench_curve_outer = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/trench/curve_outer.nbt"));
|
|
||||||
public static final NBTStructure trench_curve_inner = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/trench/curve_inner.nbt"));
|
|
||||||
public static final NBTStructure trench_bunker_small = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/trench/bunker_small.nbt"));
|
|
||||||
public static final NBTStructure trench_bunker_large = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/trench/bunker_large.nbt"));
|
|
||||||
public static final NBTStructure trench_bunker_fuel = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/trench/bunker_fuel.nbt"));
|
|
||||||
public static final NBTStructure trench_bunker_collapsed = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/trench/bunker_collapsed.nbt"));
|
|
||||||
public static final NBTStructure trench_bunker_folly = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/trench/bunker_folly.nbt"));
|
|
||||||
|
|
||||||
public static SpawnCondition TRENCH = new SpawnCondition() {{
|
|
||||||
canSpawn = biome -> biome == BiomeGenNoMansLand.noMansLand;
|
|
||||||
sizeLimit = 128;
|
|
||||||
startPool = "trench";
|
|
||||||
spawnWeight = 200;
|
|
||||||
pools = new HashMap<String, NBTStructure.JigsawPool>() {{
|
|
||||||
put("trench", new JigsawPool() {{
|
|
||||||
add(new JigsawPiece("trench_straight", StructureManager.trench_straight) {{ heightOffset = -4; conformToTerrain = true; }}, 100);
|
|
||||||
add(new JigsawPiece("trench_straight_dirt", StructureManager.trench_straight_dirt) {{ heightOffset = -4; conformToTerrain = true; }}, 100);
|
|
||||||
add(new JigsawPiece("trench_straight_bridge", StructureManager.trench_straight_bridge) {{ heightOffset = -4; conformToTerrain = true; }}, 100);
|
|
||||||
add(new JigsawPiece("trench_straight_stairs", StructureManager.trench_straight_stairs) {{ heightOffset = -4; conformToTerrain = true; }}, 100);
|
|
||||||
add(new JigsawPiece("trench_straight_door_left", StructureManager.trench_straight_door_left) {{ heightOffset = -4; conformToTerrain = true; }}, 100);
|
|
||||||
add(new JigsawPiece("trench_straight_door_right", StructureManager.trench_straight_door_right) {{ heightOffset = -4; conformToTerrain = true; }}, 100);
|
|
||||||
add(new JigsawPiece("trench_s_left", StructureManager.trench_s_left) {{ heightOffset = -4; conformToTerrain = true; }}, 100);
|
|
||||||
add(new JigsawPiece("trench_s_right", StructureManager.trench_s_right) {{ heightOffset = -4; conformToTerrain = true; }}, 100);
|
|
||||||
add(new JigsawPiece("trench_end_left", StructureManager.trench_end_left) {{ heightOffset = -4; conformToTerrain = true; }}, 100);
|
|
||||||
add(new JigsawPiece("trench_end_right", StructureManager.trench_end_right) {{ heightOffset = -4; conformToTerrain = true; }}, 100);
|
|
||||||
add(new JigsawPiece("trench_curve_outer", StructureManager.trench_curve_outer) {{ heightOffset = -4; conformToTerrain = true; }}, 100);
|
|
||||||
add(new JigsawPiece("trench_curve_inner", StructureManager.trench_curve_inner) {{ heightOffset = -4; conformToTerrain = true; }}, 100);
|
|
||||||
add(new JigsawPiece("trench_t_outer", StructureManager.trench_t_outer) {{ heightOffset = -4; conformToTerrain = true; }}, 100);
|
|
||||||
add(new JigsawPiece("trench_t_inner", StructureManager.trench_t_inner) {{ heightOffset = -4; conformToTerrain = true; }}, 100);
|
|
||||||
add(new JigsawPiece("trench_cross", StructureManager.trench_cross) {{ heightOffset = -4; conformToTerrain = true; }}, 100);
|
|
||||||
}});
|
|
||||||
put("bunker", new JigsawPool() {{
|
|
||||||
add(new JigsawPiece("trench_bunker_small", StructureManager.trench_bunker_small) {{ heightOffset = -6; }}, 100);
|
|
||||||
add(new JigsawPiece("trench_bunker_large", StructureManager.trench_bunker_large) {{ heightOffset = -6; }}, 100);
|
|
||||||
add(new JigsawPiece("trench_bunker_fuel", StructureManager.trench_bunker_fuel) {{ heightOffset = -3; }}, 100);
|
|
||||||
add(new JigsawPiece("trench_bunker_collapsed", StructureManager.trench_bunker_collapsed) {{ heightOffset = -3; }}, 100);
|
|
||||||
add(new JigsawPiece("trench_bunker_folly", StructureManager.trench_bunker_folly) {{ heightOffset = -3; }}, 100);
|
|
||||||
}});
|
|
||||||
}};
|
|
||||||
}};
|
|
||||||
|
|
||||||
public NTMWorldGenerator() {
|
public NTMWorldGenerator() {
|
||||||
final List<BiomeGenBase> invalidBiomes = Arrays.asList(new BiomeGenBase[] {BiomeGenBase.ocean, BiomeGenBase.river, BiomeGenBase.frozenOcean, BiomeGenBase.frozenRiver, BiomeGenBase.deepOcean});
|
final List<BiomeGenBase> invalidBiomes = Arrays.asList(new BiomeGenBase[] {BiomeGenBase.ocean, BiomeGenBase.river, BiomeGenBase.frozenOcean, BiomeGenBase.frozenRiver, BiomeGenBase.deepOcean});
|
||||||
final List<BiomeGenBase> oceanBiomes = Arrays.asList(new BiomeGenBase[] { BiomeGenBase.ocean, BiomeGenBase.deepOcean });
|
final List<BiomeGenBase> oceanBiomes = Arrays.asList(new BiomeGenBase[] { BiomeGenBase.ocean, BiomeGenBase.deepOcean });
|
||||||
@ -104,7 +49,46 @@ public class NTMWorldGenerator implements IWorldGenerator {
|
|||||||
}});
|
}});
|
||||||
|
|
||||||
/// TRENCH ///
|
/// TRENCH ///
|
||||||
NBTStructure.registerStructure(0, TRENCH);
|
NBTStructure.registerStructure(0, new SpawnCondition() {{
|
||||||
|
canSpawn = biome -> biome == BiomeGenNoMansLand.noMansLand;
|
||||||
|
sizeLimit = 128;
|
||||||
|
startPool = "trench";
|
||||||
|
spawnWeight = 200;
|
||||||
|
pools = new HashMap<String, NBTStructure.JigsawPool>() {{
|
||||||
|
put("trench", new JigsawPool() {{
|
||||||
|
add(new JigsawPiece("trench_straight", StructureManager.trench_straight) {{ heightOffset = -4; conformToTerrain = true; }}, 100);
|
||||||
|
add(new JigsawPiece("trench_straight_dirt", StructureManager.trench_straight_dirt) {{ heightOffset = -4; conformToTerrain = true; }}, 100);
|
||||||
|
add(new JigsawPiece("trench_straight_bridge", StructureManager.trench_straight_bridge) {{ heightOffset = -4; conformToTerrain = true; }}, 100);
|
||||||
|
add(new JigsawPiece("trench_straight_stairs", StructureManager.trench_straight_stairs) {{ heightOffset = -4; conformToTerrain = true; }}, 100);
|
||||||
|
add(new JigsawPiece("trench_straight_door_left", StructureManager.trench_straight_door_left) {{ heightOffset = -4; conformToTerrain = true; }}, 100);
|
||||||
|
add(new JigsawPiece("trench_straight_door_right", StructureManager.trench_straight_door_right) {{ heightOffset = -4; conformToTerrain = true; }}, 100);
|
||||||
|
add(new JigsawPiece("trench_s_left", StructureManager.trench_s_left) {{ heightOffset = -4; conformToTerrain = true; }}, 100);
|
||||||
|
add(new JigsawPiece("trench_s_right", StructureManager.trench_s_right) {{ heightOffset = -4; conformToTerrain = true; }}, 100);
|
||||||
|
add(new JigsawPiece("trench_end_left", StructureManager.trench_end_left) {{ heightOffset = -4; conformToTerrain = true; }}, 100);
|
||||||
|
add(new JigsawPiece("trench_end_right", StructureManager.trench_end_right) {{ heightOffset = -4; conformToTerrain = true; }}, 100);
|
||||||
|
add(new JigsawPiece("trench_curve_outer", StructureManager.trench_curve_outer) {{ heightOffset = -4; conformToTerrain = true; }}, 100);
|
||||||
|
add(new JigsawPiece("trench_curve_inner", StructureManager.trench_curve_inner) {{ heightOffset = -4; conformToTerrain = true; }}, 100);
|
||||||
|
add(new JigsawPiece("trench_t_outer", StructureManager.trench_t_outer) {{ heightOffset = -4; conformToTerrain = true; }}, 100);
|
||||||
|
add(new JigsawPiece("trench_t_inner", StructureManager.trench_t_inner) {{ heightOffset = -4; conformToTerrain = true; }}, 100);
|
||||||
|
add(new JigsawPiece("trench_cross", StructureManager.trench_cross) {{ heightOffset = -4; conformToTerrain = true; }}, 100);
|
||||||
|
}});
|
||||||
|
put("bunker", new JigsawPool() {{
|
||||||
|
add(new JigsawPiece("trench_bunker_small", StructureManager.trench_bunker_small) {{ heightOffset = -6; }}, 100);
|
||||||
|
add(new JigsawPiece("trench_bunker_large", StructureManager.trench_bunker_large) {{ heightOffset = -6; }}, 100);
|
||||||
|
add(new JigsawPiece("trench_bunker_fuel", StructureManager.trench_bunker_fuel) {{ heightOffset = -3; }}, 100);
|
||||||
|
add(new JigsawPiece("trench_bunker_collapsed", StructureManager.trench_bunker_collapsed) {{ heightOffset = -3; }}, 100);
|
||||||
|
add(new JigsawPiece("trench_bunker_folly", StructureManager.trench_bunker_folly) {{ heightOffset = -3; }}, 100);
|
||||||
|
}});
|
||||||
|
}};
|
||||||
|
}});
|
||||||
|
|
||||||
|
NBTStructure.getJiggyWithIt("trench_bunker", new JigsawPool() {{
|
||||||
|
add(new JigsawPiece("tandem:trench_bunker_small", StructureManager.trench_bunker_small), 100);
|
||||||
|
add(new JigsawPiece("tandem:trench_bunker_large", StructureManager.trench_bunker_large), 100);
|
||||||
|
add(new JigsawPiece("tandem:trench_bunker_fuel", StructureManager.trench_bunker_fuel), 100);
|
||||||
|
add(new JigsawPiece("tandem:trench_bunker_collapsed", StructureManager.trench_bunker_collapsed), 100);
|
||||||
|
add(new JigsawPiece("tandem:trench_bunker_folly", StructureManager.trench_bunker_folly), 100);
|
||||||
|
}});
|
||||||
|
|
||||||
NBTStructure.registerStructure(0, new SpawnCondition() {{
|
NBTStructure.registerStructure(0, new SpawnCondition() {{
|
||||||
canSpawn = biome -> !invalidBiomes.contains(biome);
|
canSpawn = biome -> !invalidBiomes.contains(biome);
|
||||||
|
|||||||
BIN
src/main/resources/assets/hbm/textures/blocks/wand_tandem.png
Normal file
BIN
src/main/resources/assets/hbm/textures/blocks/wand_tandem.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 543 B |
Binary file not shown.
|
After Width: | Height: | Size: 557 B |
Binary file not shown.
|
After Width: | Height: | Size: 549 B |
Binary file not shown.
|
After Width: | Height: | Size: 562 B |
Loading…
x
Reference in New Issue
Block a user