Structure nonsense part 1

This commit is contained in:
70000hp 2026-01-29 09:57:03 -05:00
parent 9ab06bab51
commit ea92109c3e
23 changed files with 341 additions and 92 deletions

View File

@ -5,6 +5,7 @@ import com.hbm.blocks.IBlockSideRotation;
import com.hbm.blocks.ILookOverlay; import com.hbm.blocks.ILookOverlay;
import com.hbm.blocks.ITooltipProvider; import com.hbm.blocks.ITooltipProvider;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.config.ServerConfig;
import com.hbm.config.StructureConfig; import com.hbm.config.StructureConfig;
import com.hbm.interfaces.IBomb; import com.hbm.interfaces.IBomb;
import com.hbm.interfaces.ICopiable; import com.hbm.interfaces.ICopiable;
@ -265,7 +266,7 @@ public class BlockWandLogic extends BlockContainer implements ILookOverlay, IToo
@Override @Override
public void transformTE(World world, int coordBaseMode) { public void transformTE(World world, int coordBaseMode) {
triggerReplace = !StructureConfig.debugStructures; triggerReplace = !ServerConfig.STRUCTURE_DEBUG.get();
} }
@Override @Override

View File

@ -9,6 +9,7 @@ import com.hbm.blocks.IBlockSideRotation;
import com.hbm.blocks.ILookOverlay; import com.hbm.blocks.ILookOverlay;
import com.hbm.blocks.ITooltipProvider; import com.hbm.blocks.ITooltipProvider;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.config.ServerConfig;
import com.hbm.config.StructureConfig; import com.hbm.config.StructureConfig;
import com.hbm.itempool.ItemPool; import com.hbm.itempool.ItemPool;
import com.hbm.lib.RefStrings; import com.hbm.lib.RefStrings;
@ -303,7 +304,7 @@ public class BlockWandLoot extends BlockContainer implements ILookOverlay, ITool
@Override @Override
public void transformTE(World world, int coordBaseMode) { public void transformTE(World world, int coordBaseMode) {
triggerReplace = !StructureConfig.debugStructures; triggerReplace = !ServerConfig.STRUCTURE_DEBUG.get();
placedRotation = MathHelper.wrapAngleTo180_float(placedRotation + coordBaseMode * 90); placedRotation = MathHelper.wrapAngleTo180_float(placedRotation + coordBaseMode * 90);
} }
@ -356,4 +357,4 @@ public class BlockWandLoot extends BlockContainer implements ILookOverlay, ITool
} }
} }

View File

@ -8,6 +8,7 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import com.hbm.config.ServerConfig;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
import com.hbm.blocks.IBlockMulti; import com.hbm.blocks.IBlockMulti;
@ -228,8 +229,8 @@ public class BlockWandStructure extends BlockContainer implements IBlockMulti, I
File structureFile = new File(structureDirectory, name + ".nbt"); File structureFile = new File(structureDirectory, name + ".nbt");
boolean previousDebug = StructureConfig.debugStructures; boolean previousDebug = ServerConfig.STRUCTURE_DEBUG.get();
StructureConfig.debugStructures = true; ServerConfig.STRUCTURE_DEBUG.set(true);
try { try {
NBTStructure structure = new NBTStructure(structureFile); NBTStructure structure = new NBTStructure(structureFile);
@ -247,7 +248,7 @@ public class BlockWandStructure extends BlockContainer implements IBlockMulti, I
} catch (FileNotFoundException ex) { } catch (FileNotFoundException ex) {
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Could not load: file not found")); player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Could not load: file not found"));
} finally { } finally {
StructureConfig.debugStructures = previousDebug; ServerConfig.STRUCTURE_DEBUG.set(previousDebug);
} }
} }

View File

@ -59,7 +59,7 @@ public class RedBarrel extends BlockDetonatable {
} else if(this == ModBlocks.lox_barrel) { } else if(this == ModBlocks.lox_barrel) {
world.newExplosion(entity, x, y, z, 1F, false, false); world.newExplosion(entity, x, y, z, 1F, false, false);
ExplosionThermo.freeze(world, ix, iy, iz, 7); ExplosionThermo.freezer(world, ix, iy, iz, 7);
} else if(this == ModBlocks.taint_barrel) { } else if(this == ModBlocks.taint_barrel) {
world.newExplosion(entity, x, y, z, 1F, false, false); world.newExplosion(entity, x, y, z, 1F, false, false);

View File

@ -47,22 +47,22 @@ public class MachineFan extends BlockContainer implements IToolable, ITooltipPro
int l = BlockPistonBase.determineOrientation(world, x, y, z, player); int l = BlockPistonBase.determineOrientation(world, x, y, z, player);
world.setBlockMetadataWithNotify(x, y, z, l, 2); world.setBlockMetadataWithNotify(x, y, z, l, 2);
} }
@Override @Override
public int getRenderType(){ public int getRenderType(){
return -1; return -1;
} }
@Override @Override
public boolean isOpaqueCube() { public boolean isOpaqueCube() {
return false; return false;
} }
@Override @Override
public boolean renderAsNormalBlock() { public boolean renderAsNormalBlock() {
return false; return false;
} }
@Override @Override
public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) {
int meta = world.getBlockMetadata(x, y, z); int meta = world.getBlockMetadata(x, y, z);
@ -70,48 +70,49 @@ public class MachineFan extends BlockContainer implements IToolable, ITooltipPro
if(side == ForgeDirection.UP || side == ForgeDirection.DOWN) return meta != 0 && meta != 1; if(side == ForgeDirection.UP || side == ForgeDirection.DOWN) return meta != 0 && meta != 1;
if(side == ForgeDirection.NORTH || side == ForgeDirection.SOUTH) return meta != 2 && meta != 3; if(side == ForgeDirection.NORTH || side == ForgeDirection.SOUTH) return meta != 2 && meta != 3;
if(side == ForgeDirection.EAST || side == ForgeDirection.WEST) return meta != 4 && meta != 5; if(side == ForgeDirection.EAST || side == ForgeDirection.WEST) return meta != 4 && meta != 5;
return false; return false;
} }
public static class TileEntityFan extends TileEntityLoadedBase { public static class TileEntityFan extends TileEntityLoadedBase {
public float spin; public float spin;
public float prevSpin; public float prevSpin;
public boolean falloff = true; public boolean falloff = true;
public boolean suck = false;
@Override @Override
public void updateEntity() { public void updateEntity() {
this.prevSpin = this.spin; this.prevSpin = this.spin;
if(worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)) { if(worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)) {
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata()); ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata());
int range = 10; int range = 10;
int effRange = 0; int effRange = 0;
double push = 0.1; double push = 0.1;
for(int i = 1; i <= range; i++) { for(int i = 1; i <= range; i++) {
Block block = worldObj.getBlock(xCoord + dir.offsetX * i, yCoord + dir.offsetY * i, zCoord + dir.offsetZ * i); Block block = worldObj.getBlock(xCoord + dir.offsetX * i, yCoord + dir.offsetY * i, zCoord + dir.offsetZ * i);
boolean blowable = block instanceof IBlowable; boolean blowable = block instanceof IBlowable;
if(block.isNormalCube() || blowable) { if(block.isNormalCube() || blowable) {
if(!worldObj.isRemote && blowable) if(!worldObj.isRemote && blowable)
((IBlowable) block).applyFan(worldObj, xCoord + dir.offsetX * i, yCoord + dir.offsetY * i, zCoord + dir.offsetZ * i, dir, i); ((IBlowable) block).applyFan(worldObj, xCoord + dir.offsetX * i, yCoord + dir.offsetY * i, zCoord + dir.offsetZ * i, dir, i);
break; break;
} }
effRange = i; effRange = i;
} }
int x = dir.offsetX * effRange; int x = dir.offsetX * effRange;
int y = dir.offsetY * effRange; int y = dir.offsetY * effRange;
int z = dir.offsetZ * effRange; int z = dir.offsetZ * effRange;
List<Entity> affected = worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(xCoord + 0.5 + Math.min(x, 0), yCoord + 0.5 + Math.min(y, 0), zCoord + 0.5 + Math.min(z, 0), xCoord + 0.5 + Math.max(x, 0), yCoord + 0.5 + Math.max(y, 0), zCoord + 0.5 + Math.max(z, 0)).expand(0.5, 0.5, 0.5)); List<Entity> affected = worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(xCoord + 0.5 + Math.min(x, 0), yCoord + 0.5 + Math.min(y, 0), zCoord + 0.5 + Math.min(z, 0), xCoord + 0.5 + Math.max(x, 0), yCoord + 0.5 + Math.max(y, 0), zCoord + 0.5 + Math.max(z, 0)).expand(0.5, 0.5, 0.5));
for(Entity e : affected) { for(Entity e : affected) {
double coeff = push; double coeff = push;
@ -120,20 +121,21 @@ public class MachineFan extends BlockContainer implements IToolable, ITooltipPro
double dist = e.getDistance(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); double dist = e.getDistance(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5);
coeff *= 1.5 * (1 - dist / range / 2); coeff *= 1.5 * (1 - dist / range / 2);
} }
if(suck) coeff *= -1;
e.motionX += dir.offsetX * coeff; e.motionX += dir.offsetX * coeff;
e.motionY += dir.offsetY * coeff; e.motionY += dir.offsetY * coeff;
e.motionZ += dir.offsetZ * coeff; e.motionZ += dir.offsetZ * coeff;
} }
if(worldObj.isRemote && worldObj.rand.nextInt(30) == 0) { if(worldObj.isRemote && worldObj.rand.nextInt(30) == 0) {
double speed = 0.2; double speed = suck ? -0.2 : 0.2;
worldObj.spawnParticle("cloud", xCoord + 0.5 + dir.offsetX * 0.5, yCoord + 0.5 + dir.offsetY * 0.5, zCoord + 0.5 + dir.offsetZ * 0.5, dir.offsetX * speed, dir.offsetY * speed, dir.offsetZ * speed); worldObj.spawnParticle("cloud", xCoord + 0.5 + dir.offsetX * 0.5, yCoord + 0.5 + dir.offsetY * 0.5, zCoord + 0.5 + dir.offsetZ * 0.5, dir.offsetX * speed, dir.offsetY * speed, dir.offsetZ * speed);
} }
this.spin += 30; this.spin += 30;
} }
if(this.spin >= 360) { if(this.spin >= 360) {
this.prevSpin -= 360; this.prevSpin -= 360;
this.spin -= 360; this.spin -= 360;
@ -143,7 +145,7 @@ public class MachineFan extends BlockContainer implements IToolable, ITooltipPro
networkPackNT(150); networkPackNT(150);
} }
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public double getMaxRenderDistanceSquared() { public double getMaxRenderDistanceSquared() {
@ -154,22 +156,26 @@ public class MachineFan extends BlockContainer implements IToolable, ITooltipPro
public void readFromNBT(NBTTagCompound nbt) { public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt); super.readFromNBT(nbt);
this.falloff = nbt.getBoolean("falloff"); this.falloff = nbt.getBoolean("falloff");
this.suck = nbt.getBoolean("suck");
} }
@Override @Override
public void writeToNBT(NBTTagCompound nbt) { public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt); super.writeToNBT(nbt);
nbt.setBoolean("falloff", falloff); nbt.setBoolean("falloff", falloff);
nbt.setBoolean("suck", suck);
} }
@Override @Override
public void serialize(ByteBuf buf) { public void serialize(ByteBuf buf) {
buf.writeBoolean(falloff); buf.writeBoolean(falloff);
buf.writeBoolean(suck);
} }
@Override @Override
public void deserialize(ByteBuf buf) { public void deserialize(ByteBuf buf) {
falloff = buf.readBoolean(); falloff = buf.readBoolean();
suck = buf.readBoolean();
} }
} }
@ -184,7 +190,7 @@ public class MachineFan extends BlockContainer implements IToolable, ITooltipPro
if(meta == 3) world.setBlockMetadataWithNotify(x, y, z, 2, 3); if(meta == 3) world.setBlockMetadataWithNotify(x, y, z, 2, 3);
if(meta == 4) world.setBlockMetadataWithNotify(x, y, z, 5, 3); if(meta == 4) world.setBlockMetadataWithNotify(x, y, z, 5, 3);
if(meta == 5) world.setBlockMetadataWithNotify(x, y, z, 4, 3); if(meta == 5) world.setBlockMetadataWithNotify(x, y, z, 4, 3);
return true; return true;
} }
@ -202,6 +208,24 @@ public class MachineFan extends BlockContainer implements IToolable, ITooltipPro
} }
} }
return true;
}
if(tool == ToolType.WRENCH) {
TileEntityFan tile = (TileEntityFan) world.getTileEntity(x, y, z);
if(tile != null) {
tile.suck = !tile.suck;
tile.markDirty();
if(!world.isRemote) {
PacketDispatcher.wrapper.sendTo(new PlayerInformPacket(ChatBuilder.start("").nextTranslation(this.getUnlocalizedName() + (tile.suck ? ".suckOn" : ".suckOff")).color(EnumChatFormatting.GOLD).flush(), MainRegistry.proxy.ID_FAN_MODE), (EntityPlayerMP) player);
world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, "random.click", 0.5F, 0.5F);
}
}
return true; return true;
} }

View File

@ -7,6 +7,9 @@ import com.hbm.inventory.recipes.loader.SerializableRecipe;
import com.hbm.util.ChatBuilder; import com.hbm.util.ChatBuilder;
import com.hbm.util.DamageResistanceHandler; import com.hbm.util.DamageResistanceHandler;
import com.hbm.world.gen.util.LogicBlockActions;
import com.hbm.world.gen.util.LogicBlockConditions;
import com.hbm.world.gen.util.LogicBlockInteractions;
import net.minecraft.command.CommandBase; import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender; import net.minecraft.command.ICommandSender;
import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatComponentText;
@ -34,6 +37,11 @@ public class CommandReloadRecipes extends CommandBase {
ItemPoolConfigJSON.initialize(); ItemPoolConfigJSON.initialize();
DamageResistanceHandler.init(); DamageResistanceHandler.init();
LogicBlockActions.initialize();
LogicBlockConditions.initialize();
LogicBlockInteractions.initialize();
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Reload complete :)")); sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Reload complete :)"));
} catch(Exception ex) { } catch(Exception ex) {
sender.addChatMessage(ChatBuilder.start("----------------------------------").color(EnumChatFormatting.GRAY).flush()); sender.addChatMessage(ChatBuilder.start("----------------------------------").color(EnumChatFormatting.GRAY).flush());

View File

@ -21,6 +21,8 @@ public class ServerConfig extends RunningConfig {
public static ConfigWrapper<Boolean> CRATE_KEEP_CONTENTS = new ConfigWrapper(true); public static ConfigWrapper<Boolean> CRATE_KEEP_CONTENTS = new ConfigWrapper(true);
public static ConfigWrapper<Integer> ITEM_HAZARD_DROP_TICKRATE = new ConfigWrapper(2); public static ConfigWrapper<Integer> ITEM_HAZARD_DROP_TICKRATE = new ConfigWrapper(2);
public static ConfigWrapper<Boolean> ENABLE_MKU = new ConfigWrapper(true); public static ConfigWrapper<Boolean> ENABLE_MKU = new ConfigWrapper(true);
public static ConfigWrapper<Boolean> STRUCTURE_DEBUG = new ConfigWrapper(false);
private static void initDefaults() { private static void initDefaults() {
configMap.put("DAMAGE_COMPATIBILITY_MODE", DAMAGE_COMPATIBILITY_MODE); configMap.put("DAMAGE_COMPATIBILITY_MODE", DAMAGE_COMPATIBILITY_MODE);
@ -34,6 +36,7 @@ public class ServerConfig extends RunningConfig {
configMap.put("CRATE_KEEP_CONTENTS", CRATE_KEEP_CONTENTS); configMap.put("CRATE_KEEP_CONTENTS", CRATE_KEEP_CONTENTS);
configMap.put("ITEM_HAZARD_DROP_TICKRATE", ITEM_HAZARD_DROP_TICKRATE); configMap.put("ITEM_HAZARD_DROP_TICKRATE", ITEM_HAZARD_DROP_TICKRATE);
configMap.put("ENABLE_MKU", ENABLE_MKU); configMap.put("ENABLE_MKU", ENABLE_MKU);
configMap.put("STRUCTURE_DEBUG", STRUCTURE_DEBUG);
} }
/** Initializes defaults, then reads the config file if it exists, then writes the config file. */ /** Initializes defaults, then reads the config file if it exists, then writes the config file. */

View File

@ -27,6 +27,8 @@ public class ItemPoolsPile {
public static final String POOL_PILE_MAKESHIFT_WIRE = "POOL_PILE_MAKESHIFT_WIRE"; public static final String POOL_PILE_MAKESHIFT_WIRE = "POOL_PILE_MAKESHIFT_WIRE";
public static final String POOL_PILE_NUKE_STORAGE = "POOL_PILE_NUKE_STORAGE"; public static final String POOL_PILE_NUKE_STORAGE = "POOL_PILE_NUKE_STORAGE";
public static final String POOL_PILE_OF_GARBAGE = "POOL_PILE_OF_GARBAGE"; public static final String POOL_PILE_OF_GARBAGE = "POOL_PILE_OF_GARBAGE";
public static final String POOL_PILE_MECHANICAL = "POOL_PILE_MECHANICAL";
public static void init() { public static void init() {
@ -141,5 +143,19 @@ public class ItemPoolsPile {
weighted(ModItems.canned_conserve, 2, 0, 1, 5), weighted(ModItems.canned_conserve, 2, 0, 1, 5),
}; };
}}; }};
new ItemPool(POOL_PILE_MECHANICAL) {{
this.pool = new WeightedRandomChestContent[] {
weighted(ModItems.defuser, 0, 1, 1, 5),
weighted(ModItems.screwdriver, 0, 1, 1, 30),
weighted(ModItems.wire_fine, Mats.MAT_COPPER.id, 8, 12, 120),
weighted(ModItems.plate_steel, 0, 3, 8, 40),
weighted(ModItems.plate_copper, 0, 2, 5, 40),
weighted(ModItems.coil_copper, 0, 2, 5, 40),
weighted(ModItems.coil_tungsten, 0, 2, 5, 40),
weighted(ModItems.ammo_standard, EnumAmmo.NUKE_TOTS.ordinal(), 1, 1, 10),
};
}};
} }
} }

View File

@ -10,6 +10,7 @@ import com.hbm.itempool.ItemPoolsSingle;
import com.hbm.lib.Library; import com.hbm.lib.Library;
import com.hbm.main.MainRegistry; import com.hbm.main.MainRegistry;
import com.hbm.main.StructureManager;
import com.hbm.tileentity.machine.storage.TileEntitySafe; import com.hbm.tileentity.machine.storage.TileEntitySafe;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item; import net.minecraft.item.Item;
@ -34,7 +35,8 @@ public class ItemWandD extends Item {
Random rand = new Random(); Random rand = new Random();
if(world.getBlock(pos.blockX, y - 1, pos.blockZ).canPlaceTorchOnTop(world, pos.blockX, y - 1, pos.blockZ)) { StructureManager.crane.build(world, pos.blockX, y, pos.blockZ);
/*if(world.getBlock(pos.blockX, y - 1, pos.blockZ).canPlaceTorchOnTop(world, pos.blockX, y - 1, pos.blockZ)) {
world.setBlock(pos.blockX, y, pos.blockZ, ModBlocks.safe, rand.nextInt(4) + 2, 2); world.setBlock(pos.blockX, y, pos.blockZ, ModBlocks.safe, rand.nextInt(4) + 2, 2);
TileEntitySafe safe = (TileEntitySafe) world.getTileEntity(pos.blockX, y, pos.blockZ); TileEntitySafe safe = (TileEntitySafe) world.getTileEntity(pos.blockX, y, pos.blockZ);
@ -64,7 +66,7 @@ public class ItemWandD extends Item {
if(GeneralConfig.enableDebugMode) if(GeneralConfig.enableDebugMode)
MainRegistry.logger.info("[Debug] Successfully spawned safe at " + pos.blockX + " " + (y + 1) +" " + pos.blockZ); MainRegistry.logger.info("[Debug] Successfully spawned safe at " + pos.blockX + " " + (y + 1) +" " + pos.blockZ);
} }*/
/*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));

View File

@ -45,6 +45,9 @@ import com.hbm.world.feature.BedrockOre;
import com.hbm.world.feature.OreCave; import com.hbm.world.feature.OreCave;
import com.hbm.world.feature.OreLayer3D; import com.hbm.world.feature.OreLayer3D;
import com.hbm.world.feature.SchistStratum; import com.hbm.world.feature.SchistStratum;
import com.hbm.world.gen.util.LogicBlockActions;
import com.hbm.world.gen.util.LogicBlockConditions;
import com.hbm.world.gen.util.LogicBlockInteractions;
import com.hbm.world.generator.CellularDungeonFactory; import com.hbm.world.generator.CellularDungeonFactory;
import cpw.mods.fml.common.*; import cpw.mods.fml.common.*;
import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.EventHandler;
@ -357,7 +360,7 @@ public class MainRegistry {
} }
} }
}); });
DispenserBehaviorHandler.init(); DispenserBehaviorHandler.init();
MicroBlocksCompatHandler.preInit(); MicroBlocksCompatHandler.preInit();
} }
@ -547,7 +550,7 @@ public class MainRegistry {
// IMPORTANT: fluids have to load before recipes. weird shit happens if not. // IMPORTANT: fluids have to load before recipes. weird shit happens if not.
Fluids.reloadFluids(); Fluids.reloadFluids();
FluidContainerRegistry.register(); FluidContainerRegistry.register();
MagicRecipes.register(); MagicRecipes.register();
LemegetonRecipes.register(); LemegetonRecipes.register();
SILEXRecipes.register(); SILEXRecipes.register();
@ -580,6 +583,10 @@ public class MainRegistry {
MobUtil.intializeMobPools(); MobUtil.intializeMobPools();
LogicBlockActions.initialize();
LogicBlockConditions.initialize();
LogicBlockInteractions.initialize();
proxy.registerMissileItems(); proxy.registerMissileItems();
// Load compatibility for OC. // Load compatibility for OC.

View File

@ -87,6 +87,9 @@ public class StructureManager {
public static final NBTStructure crane = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/crane.nbt")); public static final NBTStructure crane = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/crane.nbt"));
public static final NBTStructure broadcasting_tower = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/broadcasting_tower.nbt")); public static final NBTStructure broadcasting_tower = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/broadcasting_tower.nbt"));
public static final NBTStructure excavator = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/excavator.nbt"));
public static final NBTStructure repeater_radio = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/repeater_radio.nbt"));
public static final NBTStructure spire = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/spire.nbt")); public static final NBTStructure spire = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/spire.nbt"));
// public static final NBTStructure test_rot = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/test-rot.nbt")); // public static final NBTStructure test_rot = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/test-rot.nbt"));

View File

@ -29,6 +29,11 @@ public abstract class TileEntityLockableBase extends TileEntityLoadedBase {
markDirty(); markDirty();
} }
public void unlock() {
isLocked = false;
markDirty();
}
public void setPins(int pins) { lock = pins; markDirty(); } public void setPins(int pins) { lock = pins; markDirty(); }
public int getPins() { return lock; } public int getPins() { return lock; }
public void setMod(double mod) { lockMod = mod; markDirty(); } public void setMod(double mod) { lockMod = mod; markDirty(); }

View File

@ -30,6 +30,7 @@ public class LootGenerator {
public static final String LOOT_METEOR = "LOOT_METEOR"; public static final String LOOT_METEOR = "LOOT_METEOR";
public static final String LOOT_FLAREGUN = "LOOT_FLAREGUN"; public static final String LOOT_FLAREGUN = "LOOT_FLAREGUN";
public static final String LOOT_SHIT = "LOOT_SHIT"; public static final String LOOT_SHIT = "LOOT_SHIT";
public static final String LOOT_MECHANICAL = "LOOT_MECHANICAL";
public static void applyLoot(World world, int x, int y, int z, String name) { public static void applyLoot(World world, int x, int y, int z, String name) {
switch(name) { switch(name) {
@ -44,6 +45,7 @@ public class LootGenerator {
case LOOT_METEOR: lootBookMeteor(world, x, y, z); case LOOT_METEOR: lootBookMeteor(world, x, y, z);
case LOOT_FLAREGUN: lootFlareGun(world, x, y, z); case LOOT_FLAREGUN: lootFlareGun(world, x, y, z);
case LOOT_SHIT: lootShit(world, x, y, z); case LOOT_SHIT: lootShit(world, x, y, z);
case LOOT_MECHANICAL: lootMechanical(world, x, y, z);
default: lootBones(world, x, y, z); break; default: lootBones(world, x, y, z); break;
} }
} }
@ -60,6 +62,7 @@ public class LootGenerator {
LOOT_GLYPHID_HIVE, LOOT_GLYPHID_HIVE,
LOOT_METEOR, LOOT_METEOR,
LOOT_FLAREGUN, LOOT_FLAREGUN,
LOOT_MECHANICAL,
}; };
} }
@ -247,4 +250,17 @@ public class LootGenerator {
} }
} }
} }
public static void lootMechanical(World world, int x, int y, int z) {
TileEntityLoot loot = (TileEntityLoot) world.getTileEntity(x, y, z);
if(loot != null && loot.items.isEmpty()) {
int limit = world.rand.nextInt(3) + 1;
for(int i = 0; i < limit; i++) {
addItemWithDeviation(loot, world.rand, ItemPool.getStack(ItemPool.getPool(ItemPoolsPile.POOL_PILE_MECHANICAL), world.rand), world.rand.nextDouble() - 0.5, i * 0.03125, world.rand.nextDouble() - 0.5);
}
}
}
} }

View File

@ -9,6 +9,7 @@ import java.io.InputStream;
import java.util.*; import java.util.*;
import java.util.function.Predicate; import java.util.function.Predicate;
import com.hbm.config.ServerConfig;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
@ -80,7 +81,7 @@ public class NBTStructure {
private Map<String, List<JigsawConnection>> toTopConnections; private Map<String, List<JigsawConnection>> toTopConnections;
private Map<String, List<JigsawConnection>> toBottomConnections; private Map<String, List<JigsawConnection>> toBottomConnections;
private Map<String, List<JigsawConnection>> toHorizontalConnections; private Map<String, List<JigsawConnection>> toHorizontalConnections;
// incredibly shitty system for translating legacy block definitions to new ones // incredibly shitty system for translating legacy block definitions to new ones
@Untested // i can't find a god damn factory @Untested // i can't find a god damn factory
private static Map<String, String> substitutions = new HashMap() {{ private static Map<String, String> substitutions = new HashMap() {{
@ -328,7 +329,7 @@ public class NBTStructure {
String blockName = p.getString("Name"); String blockName = p.getString("Name");
NBTTagCompound prop = p.getCompoundTag("Properties"); NBTTagCompound prop = p.getCompoundTag("Properties");
/// BOB PATCH /// /// BOB PATCH ///
if(substitutions.containsKey(blockName)) blockName = substitutions.get(blockName); if(substitutions.containsKey(blockName)) blockName = substitutions.get(blockName);
/// BOB PATCH /// /// BOB PATCH ///
@ -343,7 +344,7 @@ public class NBTStructure {
palette[i] = new BlockDefinition(blockName, meta); palette[i] = new BlockDefinition(blockName, meta);
if(StructureConfig.debugStructures && palette[i].block == Blocks.air) { if(ServerConfig.STRUCTURE_DEBUG.get() && palette[i].block == Blocks.air) {
palette[i] = new BlockDefinition(ModBlocks.wand_air, meta); palette[i] = new BlockDefinition(ModBlocks.wand_air, meta);
} }
} }
@ -416,7 +417,7 @@ public class NBTStructure {
List<JigsawConnection> namedConnections = toConnections.computeIfAbsent(ourName, name -> new ArrayList<>()); List<JigsawConnection> namedConnections = toConnections.computeIfAbsent(ourName, name -> new ArrayList<>());
namedConnections.add(connection); namedConnections.add(connection);
if(!StructureConfig.debugStructures) { if(!ServerConfig.STRUCTURE_DEBUG.get()) {
blockState = new BlockState(new BlockDefinition(replaceBlock, replaceMeta)); blockState = new BlockState(new BlockDefinition(replaceBlock, replaceMeta));
} }
} }

View File

@ -5,6 +5,7 @@ import java.util.Random;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.Predicate; import java.util.function.Predicate;
import com.hbm.config.ServerConfig;
import com.hbm.config.StructureConfig; import com.hbm.config.StructureConfig;
import com.hbm.util.Tuple.Pair; import com.hbm.util.Tuple.Pair;
import com.hbm.util.Tuple.Quartet; import com.hbm.util.Tuple.Quartet;
@ -109,7 +110,7 @@ public class SpawnCondition {
// Make sure structure debug is enabled, or it will no-op // Make sure structure debug is enabled, or it will no-op
// Do not use in generation // Do not use in generation
public void buildAll(World world, int x, int y, int z) { public void buildAll(World world, int x, int y, int z) {
if(!StructureConfig.debugStructures) return; if(!ServerConfig.STRUCTURE_DEBUG.get()) return;
int padding = 5; int padding = 5;
int oz = 0; int oz = 0;
@ -148,4 +149,4 @@ public class SpawnCondition {
} }
} }

View File

@ -10,6 +10,8 @@ import com.hbm.entity.mob.EntityUndeadSoldier;
import com.hbm.items.ItemEnums; import com.hbm.items.ItemEnums;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.tileentity.TileEntityDoorGeneric; import com.hbm.tileentity.TileEntityDoorGeneric;
import com.hbm.tileentity.bomb.TileEntityCharge;
import com.hbm.tileentity.machine.TileEntityLockableBase;
import com.hbm.tileentity.machine.storage.TileEntityCrateBase; import com.hbm.tileentity.machine.storage.TileEntityCrateBase;
import com.hbm.util.ContaminationUtil; import com.hbm.util.ContaminationUtil;
import com.hbm.util.MobUtil; import com.hbm.util.MobUtil;
@ -20,6 +22,7 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.effect.EntityLightningBolt; import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.monster.EntitySkeleton; import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.monster.EntityZombie; import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -33,7 +36,7 @@ import java.util.function.Consumer;
public class LogicBlockActions { public class LogicBlockActions {
public static LinkedHashMap<String, Consumer<LogicBlock.TileEntityLogicBlock>> actions = new LinkedHashMap<>(); public static LinkedHashMap<String, Consumer<LogicBlock.TileEntityLogicBlock>> actions;
public static Consumer<LogicBlock.TileEntityLogicBlock> PHASE_ABERRATOR = (tile) -> { public static Consumer<LogicBlock.TileEntityLogicBlock> PHASE_ABERRATOR = (tile) -> {
World world = tile.getWorldObj(); World world = tile.getWorldObj();
@ -169,81 +172,91 @@ public class LogicBlockActions {
} }
}; };
public static Consumer<LogicBlock.TileEntityLogicBlock> SKELETON_GUN_TIER_1 = (tile) -> { public static Consumer<LogicBlock.TileEntityLogicBlock> SKELETONS_GUN_TIER_1 = (tile) -> {
World world = tile.getWorldObj(); World world = tile.getWorldObj();
int x = tile.xCoord; int x = tile.xCoord;
int y = tile.yCoord; int y = tile.yCoord;
int z = tile.zCoord; int z = tile.zCoord;
if (tile.phase == 1) { if (tile.phase == 1) {
EntitySkeleton mob = new EntitySkeleton(world); for (int i = 0; i < 3; i++) {
mob.setPositionAndRotation(x, y, z, 0, 0); EntitySkeleton mob = new EntitySkeleton(world);
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolGunsTier1, new Random()); mob.setPositionAndRotation(x, y, z, 0, 0);
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolMasks, new Random()); MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolGunsTier1, new Random());
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolRanged, new Random()); MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolMasks, new Random());
world.spawnEntityInWorld(mob); MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolRanged, new Random());
world.setBlock(x, y, z, Blocks.air); world.spawnEntityInWorld(mob);
world.setBlock(x, y, z, Blocks.air);
}
} }
}; };
public static Consumer<LogicBlock.TileEntityLogicBlock> SKELETON_GUN_TIER_2 = (tile) -> { public static Consumer<LogicBlock.TileEntityLogicBlock> SKELETONS_GUN_TIER_2 = (tile) -> {
World world = tile.getWorldObj(); World world = tile.getWorldObj();
int x = tile.xCoord; int x = tile.xCoord;
int y = tile.yCoord; int y = tile.yCoord;
int z = tile.zCoord; int z = tile.zCoord;
if (tile.phase == 1) { if (tile.phase == 1) {
EntitySkeleton mob = new EntitySkeleton(world); for (int i = 0; i < 3; i++) {
mob.setPositionAndRotation(x, y, z, 0, 0); EntitySkeleton mob = new EntitySkeleton(world);
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolGunsTier2, new Random()); mob.setPositionAndRotation(x, y, z, 0, 0);
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolMasks, new Random()); MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolGunsTier2, new Random());
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolTierArmor, new Random()); MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolMasks, new Random());
world.spawnEntityInWorld(mob); MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolTierArmor, new Random());
world.setBlock(x, y, z, Blocks.air); world.spawnEntityInWorld(mob);
world.setBlock(x, y, z, Blocks.air);
}
} }
}; };
public static Consumer<LogicBlock.TileEntityLogicBlock> SKELETON_GUN_TIER_3 = (tile) -> { public static Consumer<LogicBlock.TileEntityLogicBlock> SKELETONS_GUN_TIER_3 = (tile) -> {
World world = tile.getWorldObj(); World world = tile.getWorldObj();
int x = tile.xCoord; int x = tile.xCoord;
int y = tile.yCoord; int y = tile.yCoord;
int z = tile.zCoord; int z = tile.zCoord;
if (tile.phase == 1) { if (tile.phase == 1) {
EntitySkeleton mob = new EntitySkeleton(world); for (int i = 0; i < 3; i++) {
mob.setPositionAndRotation(x, y, z, 0, 0); EntitySkeleton mob = new EntitySkeleton(world);
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolGunsTier3, new Random()); mob.setPositionAndRotation(x, y, z, 0, 0);
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolMasks, new Random()); MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolGunsTier3, new Random());
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolAdvRanged, new Random()); MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolMasks, new Random());
world.spawnEntityInWorld(mob); MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolAdvRanged, new Random());
world.setBlock(x, y, z, Blocks.air); world.spawnEntityInWorld(mob);
world.setBlock(x, y, z, Blocks.air);
}
} }
}; };
public static Consumer<LogicBlock.TileEntityLogicBlock> ZOMBIE_TIER_1 = (tile) -> { public static Consumer<LogicBlock.TileEntityLogicBlock> ZOMBIES_TIER_1 = (tile) -> {
World world = tile.getWorldObj(); World world = tile.getWorldObj();
int x = tile.xCoord; int x = tile.xCoord;
int y = tile.yCoord; int y = tile.yCoord;
int z = tile.zCoord; int z = tile.zCoord;
if (tile.phase == 1) { if (tile.phase == 1) {
EntityZombie mob = new EntityZombie(world); for (int i = 0; i < 3; i++) {
mob.setPositionAndRotation(x, y, z, 0, 0); EntityZombie mob = new EntityZombie(world);
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolMelee, new Random()); mob.setPositionAndRotation(x, y, z, 0, 0);
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolTierArmor, new Random()); MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolMelee, new Random());
world.spawnEntityInWorld(mob); MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolTierArmor, new Random());
world.setBlock(x, y, z, Blocks.air); world.spawnEntityInWorld(mob);
world.setBlock(x, y, z, Blocks.air);
}
} }
}; };
public static Consumer<LogicBlock.TileEntityLogicBlock> ZOMBIE_TIER_2 = (tile) -> { public static Consumer<LogicBlock.TileEntityLogicBlock> ZOMBIES_TIER_2 = (tile) -> {
World world = tile.getWorldObj(); World world = tile.getWorldObj();
int x = tile.xCoord; int x = tile.xCoord;
int y = tile.yCoord; int y = tile.yCoord;
int z = tile.zCoord; int z = tile.zCoord;
if (tile.phase == 1) { if (tile.phase == 1) {
EntityZombie mob = new EntityZombie(world); for (int i = 0; i < 3; i++) {
mob.setPositionAndRotation(x, y, z, 0, 0); EntityZombie mob = new EntityZombie(world);
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolTierArmor, new Random()); mob.setPositionAndRotation(x, y, z, 0, 0);
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolMelee, new Random()); MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolTierArmor, new Random());
world.spawnEntityInWorld(mob); MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolMelee, new Random());
world.setBlock(x, y, z, Blocks.air); world.spawnEntityInWorld(mob);
world.setBlock(x, y, z, Blocks.air);
}
} }
}; };
@ -361,28 +374,109 @@ public class LogicBlockActions {
} }
}; };
public static Consumer<LogicBlock.TileEntityLogicBlock> POWER_LOCK = (tile) -> {
World world = tile.getWorldObj();
int x = tile.xCoord;
int y = tile.yCoord;
int z = tile.zCoord;
ForgeDirection parallel = tile.direction.getRotation(ForgeDirection.UP);
if(tile.phase == 0 && !world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y - 2, z + 1).expand(3, 3, 3)).isEmpty()){
world.getClosestPlayer(x,y,z, 300).addChatMessage(new ChatComponentText(
EnumChatFormatting.LIGHT_PURPLE + "[POWER LOCK]" +
EnumChatFormatting.RESET + " Low Power Warning! Locking Safe"));
tile.phase++;
TileEntityLockableBase safe = null;
if(world.getTileEntity(x - parallel.offsetX,y,z) instanceof TileEntityLockableBase)
safe = (TileEntityLockableBase) world.getTileEntity(x,y,z - parallel.offsetX);
if(safe != null){
safe.setPins(world.rand.nextInt(999));
}
}
};
public static Consumer<LogicBlock.TileEntityLogicBlock> BOMB_TRAP = (tile) -> {
World world = tile.getWorldObj();
int x = tile.xCoord;
int y = tile.yCoord;
int z = tile.zCoord;
ForgeDirection direction = tile.direction.getOpposite();
if(tile.phase == 1){
world.setBlock(x,y,z + direction.offsetZ, ModBlocks.charge_c4, 2, 3);
TileEntity te = world.getTileEntity(x,y,z + direction.offsetZ);
if(te instanceof TileEntityCharge){
TileEntityCharge bomb = (TileEntityCharge) te;
bomb.timer = 2400;
bomb.started = true;
}
world.setBlock(x,y,z, tile.disguise != null ? tile.disguise : Blocks.air);
}
};
public static Consumer<LogicBlock.TileEntityLogicBlock> BOMB_CRANE = (tile) -> {
World world = tile.getWorldObj();
int x = tile.xCoord;
int y = tile.yCoord;
int z = tile.zCoord;
ForgeDirection direction = tile.direction.getOpposite();
if(tile.phase == 1){
world.setBlock(x,y,z + direction.offsetZ, ModBlocks.charge_c4, 2, 3);
TileEntity te = world.getTileEntity(x,y,z + direction.offsetZ);
if(te instanceof TileEntityCharge){
TileEntityCharge bomb = (TileEntityCharge) te;
bomb.timer = 2400;
bomb.started = true;
}
world.setBlock(x,y,z, ModBlocks.crate_steel);
TileEntityCrateBase crate = (TileEntityCrateBase) world.getTileEntity(x,y,z);
crate.setPins(world.rand.nextInt(999));
crate.lock();
((IInventory)crate).setInventorySlotContents(15, new ItemStack(ModItems.launch_key));
}
};
public static List<String> getActionNames(){ public static List<String> getActionNames(){
return new ArrayList<>(actions.keySet()); return new ArrayList<>(actions.keySet());
} }
//register new actions here //register new actions here
static{ static{
//example actions initialize();
}
public static void initialize(){
actions = new LinkedHashMap<>();
//logic actions
actions.put("FODDER_WAVE", FODDER_WAVE); actions.put("FODDER_WAVE", FODDER_WAVE);
actions.put("ABERRATOR", PHASE_ABERRATOR); actions.put("POWER_LOCK", POWER_LOCK);
actions.put("COLLAPSE_ROOF_RAD_5", COLLAPSE_ROOF_RAD_5); actions.put("COLLAPSE_ROOF_RAD_5", COLLAPSE_ROOF_RAD_5);
actions.put("COLLAPSE_ROOF_RAD_10", COLLAPSE_ROOF_RAD_10); actions.put("COLLAPSE_ROOF_RAD_10", COLLAPSE_ROOF_RAD_10);
actions.put("BOMB_TRAP", BOMB_TRAP);
actions.put("BOMB_CRANE", BOMB_CRANE);
//Mob Block Actions
actions.put("SKELETON_GUN_TIER_1", SKELETONS_GUN_TIER_1);
actions.put("SKELETON_GUN_TIER_2", SKELETONS_GUN_TIER_2);
actions.put("SKELETON_GUN_TIER_3", SKELETONS_GUN_TIER_3);
actions.put("ZOMBIE_TIER_1", ZOMBIES_TIER_1);
actions.put("ZOMBIE_TIER_2", ZOMBIES_TIER_2);
//example actions
actions.put("ABERRATOR", PHASE_ABERRATOR);
actions.put("PUZZLE_TEST", PUZZLE_TEST); actions.put("PUZZLE_TEST", PUZZLE_TEST);
actions.put("MISSILE_STRIKE", MISSILE_STRIKE); actions.put("MISSILE_STRIKE", MISSILE_STRIKE);
actions.put("IRRADIATE_ENTITIES_AOE", RAD_CONTAINMENT_SYSTEM); actions.put("IRRADIATE_ENTITIES_AOE", RAD_CONTAINMENT_SYSTEM);
//Mob Block Actions
actions.put("SKELETON_GUN_TIER_1", SKELETON_GUN_TIER_1);
actions.put("SKELETON_GUN_TIER_2", SKELETON_GUN_TIER_2);
actions.put("SKELETON_GUN_TIER_3", SKELETON_GUN_TIER_3);
actions.put("ZOMBIE_TIER_1", ZOMBIE_TIER_1);
actions.put("ZOMBIE_TIER_2", ZOMBIE_TIER_2);
} }
} }

View File

@ -5,6 +5,7 @@ import com.hbm.blocks.generic.BlockPedestal;
import com.hbm.blocks.generic.LogicBlock; import com.hbm.blocks.generic.LogicBlock;
import com.hbm.entity.mob.EntityUndeadSoldier; import com.hbm.entity.mob.EntityUndeadSoldier;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.tileentity.machine.TileEntityLockableBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
@ -19,7 +20,7 @@ import java.util.function.Function;
public class LogicBlockConditions { public class LogicBlockConditions {
public static LinkedHashMap<String, Function<LogicBlock.TileEntityLogicBlock, Boolean>> conditions = new LinkedHashMap<>(); public static LinkedHashMap<String, Function<LogicBlock.TileEntityLogicBlock, Boolean>> conditions;
/**For use with interactions, for having them handle all conditional tasks*/ /**For use with interactions, for having them handle all conditional tasks*/
public static Function<LogicBlock.TileEntityLogicBlock, Boolean> EMPTY = (tile) -> false; public static Function<LogicBlock.TileEntityLogicBlock, Boolean> EMPTY = (tile) -> false;
@ -96,18 +97,26 @@ public class LogicBlockConditions {
&& ((BlockPedestal.TileEntityPedestal) pedestal).item.getItem() == ModItems.big_sword; && ((BlockPedestal.TileEntityPedestal) pedestal).item.getItem() == ModItems.big_sword;
}; };
public static List<String> getConditionNames(){ public static List<String> getConditionNames(){
return new ArrayList<>(conditions.keySet()); return new ArrayList<>(conditions.keySet());
} }
//register new conditions here //register new conditions here
static { static {
//example conditions initialize();
}
public static void initialize() {
conditions = new LinkedHashMap<>();
conditions.put("EMPTY", EMPTY); conditions.put("EMPTY", EMPTY);
conditions.put("ABERRATOR", ABERRATOR);
conditions.put("PLAYER_CUBE_3", PLAYER_CUBE_3); conditions.put("PLAYER_CUBE_3", PLAYER_CUBE_3);
conditions.put("PLAYER_CUBE_5", PLAYER_CUBE_5); conditions.put("PLAYER_CUBE_5", PLAYER_CUBE_5);
conditions.put("PLAYER_CUBE_25", PLAYER_CUBE_25); conditions.put("PLAYER_CUBE_25", PLAYER_CUBE_25);
//example conditions
conditions.put("ABERRATOR", ABERRATOR);
conditions.put("REDSTONE", REDSTONE); conditions.put("REDSTONE", REDSTONE);
conditions.put("PUZZLE_TEST", PUZZLE_TEST); conditions.put("PUZZLE_TEST", PUZZLE_TEST);
} }

View File

@ -1,12 +1,18 @@
package com.hbm.world.gen.util; package com.hbm.world.gen.util;
import api.hbm.energymk2.IEnergyHandlerMK2;
import com.hbm.blocks.generic.LogicBlock; import com.hbm.blocks.generic.LogicBlock;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.potion.HbmPotion; import com.hbm.potion.HbmPotion;
import com.hbm.tileentity.machine.TileEntityLockableBase;
import com.hbm.tileentity.machine.storage.TileEntityCrateBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.PotionEffect; import net.minecraft.potion.PotionEffect;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@ -18,11 +24,16 @@ public class LogicBlockInteractions {
/**Consumer consists of world instance, tile entity instance, three ints for coordinates, one int for block side, and player instance, /**Consumer consists of world instance, tile entity instance, three ints for coordinates, one int for block side, and player instance,
* in that order **/ * in that order **/
public static LinkedHashMap<String, Consumer<Object[]>> interactions = new LinkedHashMap<>(); public static LinkedHashMap<String, Consumer<Object[]>> interactions;
public static Consumer<Object[]> TEST = (array) -> { public static Consumer<Object[]> TEST = (array) -> {
World world = (World) array[0];
LogicBlock.TileEntityLogicBlock logic = (LogicBlock.TileEntityLogicBlock) array[1]; LogicBlock.TileEntityLogicBlock logic = (LogicBlock.TileEntityLogicBlock) array[1];
int x = (int) array[2];
int y = (int) array[3];
int z = (int) array[4];
EntityPlayer player = (EntityPlayer) array[5]; EntityPlayer player = (EntityPlayer) array[5];
int side = (int) array[6];
if(logic.phase > 1) return; if(logic.phase > 1) return;
@ -48,6 +59,42 @@ public class LogicBlockInteractions {
} }
}; };
public static Consumer<Object[]> POWER_LOCK = (array) -> {
World world = (World) array[0];
LogicBlock.TileEntityLogicBlock logic = (LogicBlock.TileEntityLogicBlock) array[1];
EntityPlayer player = (EntityPlayer) array[5];
int x = (int) array[2];
int y = (int) array[3];
int z = (int) array[4];
IEnergyHandlerMK2 handler = null;
ForgeDirection parallel = logic.direction.getRotation(ForgeDirection.UP);
if(world.getTileEntity(x,y + 1,z) instanceof IEnergyHandlerMK2)
handler = (IEnergyHandlerMK2) world.getTileEntity(x,y + 1,z);
if(handler == null || !(handler.getPower() > 500_000))
player.addChatMessage(new ChatComponentText(
EnumChatFormatting.LIGHT_PURPLE + "[POWER LOCK]" +
EnumChatFormatting.RESET + " Charge adjacent energy storage to at least 500KHE to release emergency lock"));
else {
player.addChatMessage(new ChatComponentText(
EnumChatFormatting.LIGHT_PURPLE + "[POWER LOCK]" +
EnumChatFormatting.RESET + " Power Restorted! Safe Unlocked!"));
TileEntityLockableBase safe = null;
if(world.getTileEntity(x - parallel.offsetX,y,z) instanceof TileEntityLockableBase)
safe = (TileEntityLockableBase) world.getTileEntity(x - parallel.offsetX,y,z);
if(safe != null){
safe.unlock();
world.playSoundAtEntity(player, "hbm:block.lockOpen", 3.0F, 0.8F);
}
}
};
public static List<String> getInteractionNames(){ public static List<String> getInteractionNames(){
@ -56,6 +103,14 @@ public class LogicBlockInteractions {
//register new interactions here //register new interactions here
static{ static{
initialize();
}
public static void initialize() {
interactions = new LinkedHashMap<>();
interactions.put("POWER_LOCK", POWER_LOCK);
//example interactions
interactions.put("TEST", TEST); interactions.put("TEST", TEST);
interactions.put("RADAWAY_INJECTOR", RAD_CONTAINMENT_SYSTEM); interactions.put("RADAWAY_INJECTOR", RAD_CONTAINMENT_SYSTEM);
} }

View File

@ -5541,6 +5541,8 @@ tile.fan.name=Fan
tile.fan.desc=Activates using redstone$Will push entities up to 10 blocks$Right-click with screwdriver to flip$Right-click with hand drill to switch mode tile.fan.desc=Activates using redstone$Will push entities up to 10 blocks$Right-click with screwdriver to flip$Right-click with hand drill to switch mode
tile.fan.falloffOn=Fan power decreases with distance tile.fan.falloffOn=Fan power decreases with distance
tile.fan.falloffOff=Consistent fan power tile.fan.falloffOff=Consistent fan power
tile.fan.suckOn=Fan is now sucking
tile.fan.suckOff=Fan is now blowing
tile.fence_metal.name=Chainlink Fence tile.fence_metal.name=Chainlink Fence
tile.fence_metal_post.name=Chainlink Fence Post tile.fence_metal_post.name=Chainlink Fence Post
tile.field_disturber.name=High Energy Field Jammer tile.field_disturber.name=High Energy Field Jammer

Binary file not shown.