Merge pull request #2930 from 70000hp/the-crane-PR-and-nonsense

Crane Structure
This commit is contained in:
HbmMods 2026-06-02 21:14:27 +02:00 committed by GitHub
commit 560c7993b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
29 changed files with 748 additions and 220 deletions

View File

@ -723,7 +723,7 @@ public class ModBlocks {
public static Block machine_battery_socket;
public static Block machine_battery_redd;
@Deprecated public static Block machine_battery_potato;
@Deprecated public static Block machine_battery;
@Deprecated public static Block machine_lithium_battery;
@ -1212,6 +1212,7 @@ public class ModBlocks {
public static Block wand_structure;
public static Block logic_block;
public static Block logic_block_invis;
public static Material materialGas = new MaterialGas();
@ -1816,7 +1817,7 @@ public class ModBlocks {
machine_battery_socket = new MachineBatterySocket().setBlockName("machine_battery_socket").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel");
machine_battery_redd = new MachineBatteryREDD().setBlockName("machine_battery_redd").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel");
machine_battery_potato = new MachineBattery(Material.iron, 10_000).setBlockName("machine_battery_potato").setHardness(5.0F).setResistance(10.0F).setCreativeTab(null);
machine_battery = new MachineBattery(Material.iron, 1_000_000).setBlockName("machine_battery").setHardness(5.0F).setResistance(10.0F).setCreativeTab(null);
machine_lithium_battery = new MachineBattery(Material.iron, 50_000_000).setBlockName("machine_lithium_battery").setHardness(5.0F).setResistance(10.0F).setCreativeTab(null);
@ -2348,6 +2349,7 @@ public class ModBlocks {
wand_structure = new BlockWandStructure().setBlockName("wand_structure");
logic_block = new LogicBlock().setBlockName("logic_block").setBlockTextureName(RefStrings.MODID + ":logic_block");
logic_block_invis = new LogicBlockInvis().setBlockName("logic_block_invis").setBlockTextureName(RefStrings.MODID + ":logic_block");
}
@ -3485,6 +3487,7 @@ public class ModBlocks {
register(wand_structure);
register(logic_block);
register(logic_block_invis);
}
private static void register(Block b) {

View File

@ -5,6 +5,7 @@ import com.hbm.blocks.IBlockSideRotation;
import com.hbm.blocks.ILookOverlay;
import com.hbm.blocks.ITooltipProvider;
import com.hbm.blocks.ModBlocks;
import com.hbm.config.ServerConfig;
import com.hbm.config.StructureConfig;
import com.hbm.interfaces.IBomb;
import com.hbm.interfaces.ICopiable;
@ -116,6 +117,7 @@ public class BlockWandLogic extends BlockContainer implements ILookOverlay, IToo
return true;
}
}
}
return super.onBlockActivated(world, x, y, z, player, side, fX, fY, fZ);
}
@ -218,7 +220,7 @@ public class BlockWandLogic extends BlockContainer implements ILookOverlay, IToo
public int placedRotation;
Block disguise;
int disguiseMeta = -1;
int disguiseMeta = 0;
public String actionID = "FODDER_WAVE";
public String conditionID = "PLAYER_CUBE_5";
@ -237,35 +239,38 @@ public class BlockWandLogic extends BlockContainer implements ILookOverlay, IToo
}
private void replace() {
if (!(worldObj.getBlock(xCoord, yCoord, zCoord) instanceof BlockWandLogic)) {
MainRegistry.logger.warn("Somehow the block at: " + xCoord + ", " + yCoord + ", " + zCoord + " isn't a logic block but we're doing a TE update as if it is, cancelling!");
return;
}
worldObj.setBlock(xCoord,yCoord,zCoord, ModBlocks.logic_block);
if(!worldObj.isRemote) {
if (!(worldObj.getBlock(xCoord, yCoord, zCoord) instanceof BlockWandLogic)) {
MainRegistry.logger.warn("Somehow the block at: " + xCoord + ", " + yCoord + ", " + zCoord + " isn't a logic block but we're doing a TE update as if it is, cancelling!");
return;
}
TileEntity te = worldObj.getTileEntity(xCoord, yCoord, zCoord);
worldObj.setBlock(xCoord, yCoord, zCoord, disguise == null ? ModBlocks.logic_block_invis : ModBlocks.logic_block, 0, 3);
if(te == null || te instanceof BlockWandLoot.TileEntityWandLoot) {
MainRegistry.logger.warn("TE for logic block set incorrectly at: " + xCoord + ", " + yCoord + ", " + zCoord + ". If you're using some sort of world generation mod, report it to the author!");
te = ModBlocks.wand_logic.createTileEntity(worldObj, 0);
worldObj.setTileEntity(xCoord, yCoord, zCoord, te);
}
TileEntity te = worldObj.getTileEntity(xCoord, yCoord, zCoord);
if(te instanceof LogicBlock.TileEntityLogicBlock){
LogicBlock.TileEntityLogicBlock logic = (LogicBlock.TileEntityLogicBlock) te;
logic.actionID = actionID;
logic.conditionID = conditionID;
logic.interactionID = interactionID;
logic.direction = ForgeDirection.getOrientation(placedRotation);
logic.disguise = disguise;
logic.disguiseMeta = disguiseMeta;
if (te == null || te instanceof BlockWandLoot.TileEntityWandLoot) {
MainRegistry.logger.warn("TE for logic block set incorrectly at: " + xCoord + ", " + yCoord + ", " + zCoord + ". If you're using some sort of world generation mod, report it to the author!");
te = ModBlocks.wand_logic.createTileEntity(worldObj, 0);
worldObj.setTileEntity(xCoord, yCoord, zCoord, te);
}
if (te instanceof LogicBlock.TileEntityLogicBlock) {
LogicBlock.TileEntityLogicBlock logic = (LogicBlock.TileEntityLogicBlock) te;
logic.actionID = actionID;
logic.conditionID = conditionID;
logic.interactionID = interactionID;
logic.direction = ForgeDirection.getOrientation(placedRotation);
logic.disguise = disguise;
logic.disguiseMeta = disguiseMeta;
}
}
}
@Override
public void transformTE(World world, int coordBaseMode) {
triggerReplace = !StructureConfig.debugStructures;
triggerReplace = !ServerConfig.STRUCTURE_DEBUG.get();
}
@Override
@ -323,6 +328,7 @@ public class BlockWandLogic extends BlockContainer implements ILookOverlay, IToo
nbt.setString("conditionID", conditionID);
if(interactionID != null)
nbt.setString("interactionID", interactionID);
nbt.setInteger("rotation", placedRotation);
if(disguise != null){
nbt.setString("disguise", GameRegistry.findUniqueIdentifierFor(disguise).toString());
nbt.setInteger("disguiseMeta", disguiseMeta);
@ -336,6 +342,7 @@ public class BlockWandLogic extends BlockContainer implements ILookOverlay, IToo
actionID = nbt.getString("actionID");
conditionID = nbt.getString("conditionID");
interactionID = nbt.getString("interactionID");
placedRotation = nbt.getInteger("disguiseMeta");
if(nbt.hasKey("disguise")){
disguise = Block.getBlockFromName(nbt.getString("disguise"));
disguiseMeta = nbt.getInteger("disguiseMeta");

View File

@ -9,11 +9,16 @@ import com.hbm.blocks.IBlockSideRotation;
import com.hbm.blocks.ILookOverlay;
import com.hbm.blocks.ITooltipProvider;
import com.hbm.blocks.ModBlocks;
import com.hbm.config.ServerConfig;
import com.hbm.config.StructureConfig;
import com.hbm.interfaces.IBomb;
import com.hbm.interfaces.ICopiable;
import com.hbm.itempool.ItemPool;
import com.hbm.items.tool.ItemLock;
import com.hbm.lib.RefStrings;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.TileEntityLoadedBase;
import com.hbm.tileentity.machine.TileEntityLockableBase;
import com.hbm.util.BufferUtil;
import com.hbm.util.LootGenerator;
import com.hbm.util.i18n.I18nUtil;
@ -33,6 +38,7 @@ import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
@ -47,7 +53,7 @@ import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.common.util.FakePlayerFactory;
public class BlockWandLoot extends BlockContainer implements ILookOverlay, IToolable, ITooltipProvider, IBlockSideRotation {
public class BlockWandLoot extends BlockContainer implements ILookOverlay, IToolable, ITooltipProvider, IBlockSideRotation, IBomb {
@SideOnly(Side.CLIENT) protected IIcon iconTop;
@ -110,6 +116,11 @@ public class BlockWandLoot extends BlockContainer implements ILookOverlay, ITool
text.add("Maximum items: " + loot.maxItems);
}
if(loot.lockCode != 0){
text.add("Container will be locked");
text.add("Lockpicking chance:" + loot.lockMod);
}
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
}
@ -148,6 +159,12 @@ public class BlockWandLoot extends BlockContainer implements ILookOverlay, ITool
}
}
ItemStack held = player.getHeldItem();
if(held != null && held.getItem() instanceof ItemLock){
loot.lockMod = (float) ((ItemLock)held.getItem()).lockMod;
loot.lockCode = ItemLock.getPins(held);
}
return false;
}
@ -211,12 +228,23 @@ public class BlockWandLoot extends BlockContainer implements ILookOverlay, ITool
}
}
@Override
public BombReturnCode explode(World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
if(!(te instanceof BlockWandLoot.TileEntityWandLoot)) return null;
((BlockWandLoot.TileEntityWandLoot) te).triggerReplace = true;
return BombReturnCode.TRIGGERED;
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityWandLoot();
}
public static class TileEntityWandLoot extends TileEntityLoadedBase implements INBTTileEntityTransformable {
public static class TileEntityWandLoot extends TileEntityLoadedBase implements INBTTileEntityTransformable, ICopiable {
private boolean triggerReplace;
@ -229,6 +257,10 @@ public class BlockWandLoot extends BlockContainer implements ILookOverlay, ITool
private float placedRotation;
private float lockMod = 0;
private int lockCode = 0;
private boolean cheesable = true;
private static final GameProfile FAKE_PROFILE = new GameProfile(UUID.fromString("839eb18c-50bc-400c-8291-9383f09763e7"), "[NTM]");
private static FakePlayer fakePlayer;
@ -266,6 +298,12 @@ public class BlockWandLoot extends BlockContainer implements ILookOverlay, ITool
worldObj.setTileEntity(xCoord, yCoord, zCoord, te);
}
if(te instanceof TileEntityLockableBase && lockCode != 0){
((TileEntityLockableBase) te).setPins(lockCode);
((TileEntityLockableBase) te).setMod(lockMod);
((TileEntityLockableBase) te).cheesable = lockMod != 0;
((TileEntityLockableBase) te).lock();
}
if(te instanceof IInventory) {
int count = minItems;
if(maxItems - minItems > 0) count += worldObj.rand.nextInt(maxItems - minItems);
@ -303,7 +341,7 @@ public class BlockWandLoot extends BlockContainer implements ILookOverlay, ITool
@Override
public void transformTE(World world, int coordBaseMode) {
triggerReplace = !StructureConfig.debugStructures;
triggerReplace = !ServerConfig.STRUCTURE_DEBUG.get();
placedRotation = MathHelper.wrapAngleTo180_float(placedRotation + coordBaseMode * 90);
}
@ -318,6 +356,10 @@ public class BlockWandLoot extends BlockContainer implements ILookOverlay, ITool
nbt.setString("pool", poolName);
nbt.setFloat("rot", placedRotation);
nbt.setInteger("lockCode", lockCode);
nbt.setFloat("lockMod", lockMod);
nbt.setBoolean("cheesable", cheesable);
nbt.setBoolean("trigger", triggerReplace);
}
@ -333,6 +375,10 @@ public class BlockWandLoot extends BlockContainer implements ILookOverlay, ITool
if(replaceBlock == null) replaceBlock = ModBlocks.deco_loot;
lockCode = nbt.getInteger("lockCode");
lockMod = nbt.getFloat("lockMod");
cheesable = nbt.getBoolean("cheesable");
triggerReplace = nbt.getBoolean("trigger");
}
@ -343,6 +389,11 @@ public class BlockWandLoot extends BlockContainer implements ILookOverlay, ITool
buf.writeInt(minItems);
buf.writeInt(maxItems);
BufferUtil.writeString(buf, poolName);
buf.writeInt(lockCode);
buf.writeFloat(lockMod);
buf.writeBoolean(cheesable);
}
@Override
@ -352,8 +403,43 @@ public class BlockWandLoot extends BlockContainer implements ILookOverlay, ITool
minItems = buf.readInt();
maxItems = buf.readInt();
poolName = BufferUtil.readString(buf);
lockCode = buf.readInt();
lockMod = buf.readFloat();
cheesable = buf.readBoolean();
}
@Override
public NBTTagCompound getSettings(World world, int x, int y, int z) {
NBTTagCompound nbt = new NBTTagCompound();
Block block = replaceBlock != null ? replaceBlock : ModBlocks.deco_loot;
nbt.setInteger("replaceBlock", Block.getIdFromBlock(block));
nbt.setInteger("replaceMeta", replaceMeta);
nbt.setInteger("minItems", minItems);
nbt.setInteger("maxItems", maxItems);
nbt.setString("poolName", poolName);
nbt.setInteger("lockCode", lockCode);
nbt.setFloat("lockMod", lockMod);
nbt.setBoolean("cheesable", cheesable);
return nbt;
}
@Override
public void pasteSettings(NBTTagCompound nbt, int index, World world, EntityPlayer player, int x, int y, int z) {
replaceBlock = Block.getBlockById(nbt.getInteger("replaceBlock"));
replaceMeta = nbt.getInteger("replaceMeta");
minItems = nbt.getInteger("minItems");
maxItems = nbt.getInteger("maxItems");
poolName = nbt.getString("poolName");
lockCode = nbt.getInteger("lockCode");
lockMod = nbt.getFloat("lockMod");
cheesable = nbt.getBoolean("cheesable");
}
}
}
}

View File

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

View File

@ -1,5 +1,7 @@
package com.hbm.blocks.generic;
import com.hbm.blocks.IBlockSideRotation;
import com.hbm.blocks.ModBlocks;
import com.hbm.world.gen.util.LogicBlockActions;
import com.hbm.world.gen.util.LogicBlockConditions;
import com.hbm.world.gen.util.LogicBlockInteractions;
@ -50,6 +52,15 @@ public class LogicBlock extends BlockContainer {
return super.getIcon(world, x, y, z, side);
}
/*
@Override
public boolean isOpaqueCube() {
return this != ModBlocks.logic_block_invis;
this == ModBlocks.logic_block_invis ? -1 :
}*/
@Override
public boolean onBlockActivated(World worldIn, int x, int y, int z, EntityPlayer player, int side, float subX, float subY, float subZ) {
TileEntity te = worldIn.getTileEntity(x, y, z);
@ -84,6 +95,9 @@ public class LogicBlock extends BlockContainer {
public EntityPlayer player;
public ForgeDirection direction = ForgeDirection.UNKNOWN;
boolean disguised = false;
@Override
public void updateEntity() {
@ -110,8 +124,14 @@ public class LogicBlock extends BlockContainer {
timer++;
}
}
if(!disguised){
markDirty();
worldObj.markBlockForUpdate(xCoord,yCoord,zCoord);
disguised = true;
}
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
@ -156,6 +176,7 @@ public class LogicBlock extends BlockContainer {
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
this.readFromNBT(pkt.func_148857_g());
worldObj.markBlockForUpdate(xCoord,yCoord,zCoord);
}
}

View File

@ -0,0 +1,21 @@
package com.hbm.blocks.generic;
import com.hbm.blocks.IBlockSideRotation;
import net.minecraft.block.material.Material;
public class LogicBlockInvis extends LogicBlock{
public LogicBlockInvis() {
super();
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public int getRenderType() {
return -1;
}
}

View File

@ -59,7 +59,7 @@ public class RedBarrel extends BlockDetonatable {
} else if(this == ModBlocks.lox_barrel) {
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) {
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);
world.setBlockMetadataWithNotify(x, y, z, l, 2);
}
@Override
public int getRenderType(){
return -1;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) {
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.NORTH || side == ForgeDirection.SOUTH) return meta != 2 && meta != 3;
if(side == ForgeDirection.EAST || side == ForgeDirection.WEST) return meta != 4 && meta != 5;
return false;
}
public static class TileEntityFan extends TileEntityLoadedBase {
public float spin;
public float prevSpin;
public boolean falloff = true;
public boolean suck = false;
@Override
public void updateEntity() {
this.prevSpin = this.spin;
if(worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)) {
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata());
int range = 10;
int effRange = 0;
double push = 0.1;
for(int i = 1; i <= range; i++) {
Block block = worldObj.getBlock(xCoord + dir.offsetX * i, yCoord + dir.offsetY * i, zCoord + dir.offsetZ * i);
boolean blowable = block instanceof IBlowable;
if(block.isNormalCube() || blowable) {
if(!worldObj.isRemote && blowable)
((IBlowable) block).applyFan(worldObj, xCoord + dir.offsetX * i, yCoord + dir.offsetY * i, zCoord + dir.offsetZ * i, dir, i);
break;
}
effRange = i;
}
int x = dir.offsetX * effRange;
int y = dir.offsetY * 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));
for(Entity e : affected) {
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);
coeff *= 1.5 * (1 - dist / range / 2);
}
if(suck) coeff *= -1;
e.motionX += dir.offsetX * coeff;
e.motionY += dir.offsetY * coeff;
e.motionZ += dir.offsetZ * coeff;
}
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);
}
this.spin += 30;
}
if(this.spin >= 360) {
this.prevSpin -= 360;
this.spin -= 360;
@ -143,7 +145,7 @@ public class MachineFan extends BlockContainer implements IToolable, ITooltipPro
networkPackNT(150);
}
}
@Override
@SideOnly(Side.CLIENT)
public double getMaxRenderDistanceSquared() {
@ -154,22 +156,26 @@ public class MachineFan extends BlockContainer implements IToolable, ITooltipPro
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.falloff = nbt.getBoolean("falloff");
this.suck = nbt.getBoolean("suck");
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setBoolean("falloff", falloff);
nbt.setBoolean("suck", suck);
}
@Override
public void serialize(ByteBuf buf) {
buf.writeBoolean(falloff);
buf.writeBoolean(suck);
}
@Override
public void deserialize(ByteBuf buf) {
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 == 4) world.setBlockMetadataWithNotify(x, y, z, 5, 3);
if(meta == 5) world.setBlockMetadataWithNotify(x, y, z, 4, 3);
return true;
}
@ -202,6 +208,24 @@ public class MachineFan extends BlockContainer implements IToolable, ITooltipPro
}
}
return true;
}
if(tool == ToolType.DEFUSER) {
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;
}

View File

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

View File

@ -21,6 +21,7 @@ public class ServerConfig extends RunningConfig {
public static ConfigWrapper<Boolean> CRATE_KEEP_CONTENTS = new ConfigWrapper(true);
public static ConfigWrapper<Integer> ITEM_HAZARD_DROP_TICKRATE = new ConfigWrapper(2);
public static ConfigWrapper<Boolean> ENABLE_MKU = new ConfigWrapper(true);
public static ConfigWrapper<Boolean> STRUCTURE_DEBUG = new ConfigWrapper(false);
public static ConfigWrapper<Integer> AUTOCAL_MAX_CLOCK = new ConfigWrapper(20);
private static void initDefaults() {
@ -35,6 +36,7 @@ public class ServerConfig extends RunningConfig {
configMap.put("CRATE_KEEP_CONTENTS", CRATE_KEEP_CONTENTS);
configMap.put("ITEM_HAZARD_DROP_TICKRATE", ITEM_HAZARD_DROP_TICKRATE);
configMap.put("ENABLE_MKU", ENABLE_MKU);
configMap.put("STRUCTURE_DEBUG", STRUCTURE_DEBUG);
configMap.put("AUTOCAL_MAX_CLOCK", AUTOCAL_MAX_CLOCK);
}

View File

@ -15,13 +15,13 @@ public class EntityAIFireGun extends EntityAIBase {
private final EntityLiving host;
private double attackMoveSpeed = 1.0D; // how fast we move while in this state
private double maxRange = 20; // how far our target can be before we stop shooting
private int burstTime = 10; // maximum number of ticks in a burst (for automatic weapons)
private int minWait = 10; // minimum number of ticks to wait between bursts/shots
private int maxWait = 40; // maximum number of ticks to wait between bursts/shots
private float inaccuracy = 30; // how many degrees of inaccuracy does the AI have
public double attackMoveSpeed = 1.0D; // how fast we move while in this state
public double maxRange = 20; // how far our target can be before we stop shooting
public int burstTime = 10; // maximum number of ticks in a burst (for automatic weapons)
public int minWait = 10; // minimum number of ticks to wait between bursts/shots
public int maxWait = 40; // maximum number of ticks to wait between bursts/shots
public float inaccuracy = 30; // how many degrees of inaccuracy does the AI have
public boolean randomBurst = true; //whether the burst time should be fixed or random
// state timers
private int attackTimer = 0;
private FireState state = FireState.IDLE;
@ -33,7 +33,7 @@ public class EntityAIFireGun extends EntityAIBase {
FIRING,
RELOADING,
}
public EntityAIFireGun(EntityLiving host) {
this.host = host;
}
@ -89,7 +89,8 @@ public class EntityAIFireGun extends EntityAIBase {
if(rec.getMagazine(stack).getAmount(stack, null) <= 0) {
updateState(FireState.RELOADING, 20, gun, stack);
} else if(ItemGunBaseNT.getState(stack, 0) == GunState.IDLE) {
updateState(FireState.FIRING, host.worldObj.rand.nextInt(burstTime), gun, stack);
int time = randomBurst ? host.worldObj.rand.nextInt(burstTime) : burstTime;
updateState(FireState.FIRING, time, gun, stack);
}
}
}
@ -114,8 +115,9 @@ public class EntityAIFireGun extends EntityAIBase {
// Turn body to face firing direction, since the gun is attached to that, not the head
// Also apply accuracy debuff just before firing
if(bind != null && bind != EnumKeybind.RELOAD) {
host.rotationYawHead += (host.worldObj.rand.nextFloat() - 0.5F) * inaccuracy;
host.rotationPitch += (host.worldObj.rand.nextFloat() - 0.5F) * inaccuracy;
float inacc = inaccuracy * (getYerGun().getConfig(stack, 0).getReceivers(stack)[0].getHipfireSpread(stack) * 20);
host.rotationYawHead += (host.worldObj.rand.nextFloat() - 0.5F) * inacc;
host.rotationPitch += (host.worldObj.rand.nextFloat() - 0.5F) * inacc;
host.rotationYaw = host.rotationYawHead;
}
@ -132,5 +134,5 @@ public class EntityAIFireGun extends EntityAIBase {
return (ItemGunBaseNT) stack.getItem();
}
}

View File

@ -3,6 +3,7 @@ package com.hbm.itempool;
import static com.hbm.lib.HbmChestContents.weighted;
import com.hbm.inventory.material.Mats;
import com.hbm.items.ItemEnums;
import com.hbm.items.ModItems;
import com.hbm.items.weapon.grenade.ItemGrenadeExtra.EnumGrenadeExtra;
import com.hbm.items.weapon.grenade.ItemGrenadeFilling.EnumGrenadeFilling;
@ -27,6 +28,9 @@ public class ItemPoolsPile {
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_OF_GARBAGE = "POOL_PILE_OF_GARBAGE";
public static final String POOL_PILE_MECHANICAL = "POOL_PILE_MECHANICAL";
public static final String POOL_PILE_GEAR = "POOL_PILE_GEAR";
public static void init() {
@ -141,5 +145,33 @@ public class ItemPoolsPile {
weighted(ModItems.canned_conserve, 2, 0, 1, 5),
};
}};
new ItemPool(POOL_PILE_MECHANICAL) {{
this.pool = new WeightedRandomChestContent[] {
weighted(ModItems.defuser, 0, 1, 1, 30),
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)
};
}};
new ItemPool(POOL_PILE_GEAR) {{
this.pool = new WeightedRandomChestContent[] {
weighted(ModItems.defuser, 0, 1, 1, 40),
weighted(ModItems.screwdriver, 0, 1, 1, 30),
weighted(ModItems.canteen_vodka,0, 1, 1, 40),
weighted(ModItems.casing, ItemEnums.EnumCasingType.SMALL_STEEL.ordinal(), 1, 4, 30),
weighted(ModItems.casing, ItemEnums.EnumCasingType.SMALL.ordinal(), 3, 8, 40),
weighted(ModItems.casing, ItemEnums.EnumCasingType.BUCKSHOT.ordinal(), 3, 8, 40),
weighted(ModItems.canned_conserve, 0, 2, 5, 40),
weighted(ModItems.taurun_helmet, 0, 1, 1, 20),
weighted(ModItems.taurun_plate, 0, 1, 1, 20),
weighted(ModItems.taurun_legs, 0, 1, 1, 20),
weighted(ModItems.taurun_boots, 0, 1, 1, 20)
};
}};
}
}

View File

@ -23,7 +23,8 @@ public class ItemPoolsSingle {
public static final String POOL_VAULT_UNBREAKABLE = "POOL_VAULT_UNBREAKABLE";
public static final String POOL_METEORITE_TREASURE = "POOL_METEORITE_TREASURE";
public static final String POOL_BLUEPRINTS = "POOL_BLUEPRINTS";
public static void init() {
new ItemPool(POOL_VAULT_RUSTY) {{
@ -43,7 +44,7 @@ public class ItemPoolsSingle {
weighted(Items.diamond, 0, 1, 2, 1)
};
}};
new ItemPool(POOL_VAULT_STANDARD) {{
this.pool = new WeightedRandomChestContent[] {
weighted(ModItems.ingot_desh, 0, 2, 6, 1),
@ -59,7 +60,7 @@ public class ItemPoolsSingle {
weighted(ModItems.circuit, EnumCircuitType.CHIP.ordinal(), 2, 6, 1)
};
}};
new ItemPool(POOL_VAULT_REINFORCED) {{
this.pool = new WeightedRandomChestContent[] {
weighted(ModItems.ingot_desh, 0, 6, 16, 1),
@ -76,7 +77,7 @@ public class ItemPoolsSingle {
weighted(ModItems.circuit, EnumCircuitType.BASIC.ordinal(), 6, 12, 1)
};
}};
new ItemPool(POOL_VAULT_UNBREAKABLE) {{
this.pool = new WeightedRandomChestContent[] {
weighted(ModItems.ammo_container, 0, 3, 6, 1),
@ -87,7 +88,7 @@ public class ItemPoolsSingle {
weighted(ModItems.circuit, EnumCircuitType.ADVANCED.ordinal(), 6, 12, 1)
};
}};
new ItemPool(POOL_METEORITE_TREASURE) {{
this.pool = new WeightedRandomChestContent[] {
weighted(ModItems.cobalt_pickaxe, 0, 1, 1, 10),
@ -111,7 +112,7 @@ public class ItemPoolsSingle {
weighted(ModItems.blueprint_folder, 1, 1, 1, 1)
};
}};
new ItemPool(POOL_BLUEPRINTS) {{
this.pool = new WeightedRandomChestContent[] {
weighted(ModItems.blueprint_folder, 0, 1, 1, 10),
@ -119,5 +120,13 @@ public class ItemPoolsSingle {
weighted(ModItems.blueprint_folder, 0, 1, 1, 1),
};
}};
new ItemPool(POOL_BLUEPRINTS) {{
this.pool = new WeightedRandomChestContent[] {
weighted(ModItems.blueprint_folder, 0, 1, 1, 10),
weighted(ModItems.blueprint_folder, 1, 1, 1, 5),
weighted(ModItems.blueprint_folder, 0, 1, 1, 1),
};
}};
}
}

View File

@ -9,36 +9,43 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
public class ItemCounterfeitKeys extends Item {
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int b, float f0, float f1, float f2) {
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileEntityLockableBase) {
TileEntityLockableBase locked = (TileEntityLockableBase) te;
if(locked.isLocked()) {
if(locked.isLocked() && locked.cheesable) {
ItemStack st = new ItemStack(ModItems.key_fake);
ItemKeyPin.setPins(st, locked.getPins());
player.inventory.setInventorySlotContents(player.inventory.currentItem, st.copy());
if(!player.inventory.addItemStackToInventory(st.copy())) {
player.dropPlayerItemWithRandomChoice(st.copy(), false);
}
player.inventoryContainer.detectAndSendChanges();
player.swingItem();
return true;
} else if(!locked.cheesable){
player.addChatMessage(new ChatComponentText(
EnumChatFormatting.LIGHT_PURPLE + "This lock is too elaborate for a counterfeit key to be made"));
player.addChatMessage(new ChatComponentText(
EnumChatFormatting.LIGHT_PURPLE + "Perhaps there is another way around here to unlock it"));
}
}
return false;
}

View File

@ -10,6 +10,7 @@ import com.hbm.itempool.ItemPoolsSingle;
import com.hbm.lib.Library;
import com.hbm.main.MainRegistry;
import com.hbm.main.StructureManager;
import com.hbm.tileentity.machine.storage.TileEntitySafe;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
@ -34,7 +35,8 @@ public class ItemWandD extends Item {
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);
TileEntitySafe safe = (TileEntitySafe) world.getTileEntity(pos.blockX, y, pos.blockZ);
@ -64,7 +66,7 @@ public class ItemWandD extends Item {
if(GeneralConfig.enableDebugMode)
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);
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.OreLayer3D;
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 cpw.mods.fml.common.*;
import cpw.mods.fml.common.Mod.EventHandler;
@ -352,7 +355,7 @@ public class MainRegistry {
}
}
});
DispenserBehaviorHandler.init();
MicroBlocksCompatHandler.preInit();
}
@ -542,7 +545,7 @@ public class MainRegistry {
// IMPORTANT: fluids have to load before recipes. weird shit happens if not.
Fluids.reloadFluids();
FluidContainerRegistry.register();
MagicRecipes.register();
LemegetonRecipes.register();
SILEXRecipes.register();
@ -575,6 +578,10 @@ public class MainRegistry {
MobUtil.intializeMobPools();
LogicBlockActions.initialize();
LogicBlockConditions.initialize();
LogicBlockInteractions.initialize();
proxy.registerMissileItems();
// Load compatibility for OC.

View File

@ -398,10 +398,10 @@ public class ModEventHandler {
MobUtil.equipFullSet(entity, ModItems.hazmat_helmet, ModItems.hazmat_plate, ModItems.hazmat_legs, ModItems.hazmat_boots);
return;
}
slotPools = MobUtil.slotPoolCommon;
slotPools = MobUtil.slotPoolCommonS;
} else if(entity instanceof EntitySkeleton) {
slotPools = MobUtil.slotPoolRanged;
slotPools = MobUtil.slotPoolRangedS;
ItemStack bowReplacement = getSkelegun(soot, world.rand);
slotPools.put(0, createSlotPool(50, bowReplacement != null ? new Object[][]{{bowReplacement, 1}} : new Object[][]{}));
}
@ -506,7 +506,7 @@ public class ModEventHandler {
@SubscribeEvent
public void onLivingUpdate(LivingUpdateEvent event) {
if(event.entityLiving instanceof EntityCreeper && event.entityLiving.getEntityData().getBoolean("hfr_defused")) {
ItemModDefuser.defuse((EntityCreeper) event.entityLiving, null, false);
}
@ -516,7 +516,7 @@ public class ModEventHandler {
if(event.entityLiving instanceof EntityPlayerMP && prevArmor != null && event.entityLiving.getHeldItem() != null
&& (prevArmor[0] == null || prevArmor[0].getItem() != event.entityLiving.getHeldItem().getItem())
&& event.entityLiving.getHeldItem().getItem() instanceof IEquipReceiver) {
((IEquipReceiver)event.entityLiving.getHeldItem().getItem()).onEquip((EntityPlayer) event.entityLiving, event.entityLiving.getHeldItem());
}
@ -1193,7 +1193,7 @@ public class ModEventHandler {
int y = event.y;
int z = event.z;
World world = event.world;
if(GeneralConfig.enable528ExplosiveEnergistics && !world.isRemote && event.action == Action.RIGHT_CLICK_BLOCK) {
Block b = world.getBlock(x, y, z);
String name = Block.blockRegistry.getNameForObject(b);

View File

@ -84,9 +84,12 @@ public class StructureManager {
public static final NBTStructure plane2 = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/crashed_plane_2.nbt"));
public static final NBTStructure factory = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/factory.nbt"));
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_mod.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 test_rot = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/test-rot.nbt"));

View File

@ -16,7 +16,8 @@ public abstract class TileEntityLockableBase extends TileEntityLoadedBase {
protected int lock;
private boolean isLocked = false;
protected double lockMod = 0.1D;
/** Whether a counterfeit lock can be made out of it*/
public boolean cheesable = true;
public boolean isLocked() {
return isLocked;
}
@ -29,6 +30,11 @@ public abstract class TileEntityLockableBase extends TileEntityLoadedBase {
markDirty();
}
public void unlock() {
isLocked = false;
markDirty();
}
public void setPins(int pins) { lock = pins; markDirty(); }
public int getPins() { return lock; }
public void setMod(double mod) { lockMod = mod; markDirty(); }
@ -39,6 +45,7 @@ public abstract class TileEntityLockableBase extends TileEntityLoadedBase {
super.readFromNBT(nbt);
lock = nbt.getInteger("lock");
cheesable = nbt.getBoolean("cheesable");
isLocked = nbt.getBoolean("isLocked");
lockMod = nbt.getDouble("lockMod");
}
@ -48,6 +55,7 @@ public abstract class TileEntityLockableBase extends TileEntityLoadedBase {
super.writeToNBT(nbt);
nbt.setInteger("lock", lock);
nbt.setBoolean("cheesable", cheesable);
nbt.setBoolean("isLocked", isLocked);
nbt.setDouble("lockMod", lockMod);
}
@ -57,6 +65,7 @@ public abstract class TileEntityLockableBase extends TileEntityLoadedBase {
super.serialize(buf);
buf.writeInt(lock);
buf.writeBoolean(cheesable);
buf.writeBoolean(isLocked);
buf.writeDouble(lockMod);
}
@ -66,6 +75,7 @@ public abstract class TileEntityLockableBase extends TileEntityLoadedBase {
super.deserialize(buf);
lock = buf.readInt();
cheesable = buf.readBoolean();
isLocked = buf.readBoolean();
lockMod = buf.readDouble();
}

View File

@ -30,6 +30,8 @@ public class LootGenerator {
public static final String LOOT_METEOR = "LOOT_METEOR";
public static final String LOOT_FLAREGUN = "LOOT_FLAREGUN";
public static final String LOOT_SHIT = "LOOT_SHIT";
public static final String LOOT_MECHANICAL = "LOOT_MECHANICAL";
public static final String LOOT_GEAR = "LOOT_GEAR";
public static void applyLoot(World world, int x, int y, int z, String name) {
switch(name) {
@ -44,6 +46,8 @@ public class LootGenerator {
case LOOT_METEOR: lootBookMeteor(world, x, y, z);
case LOOT_FLAREGUN: lootFlareGun(world, x, y, z);
case LOOT_SHIT: lootShit(world, x, y, z);
case LOOT_MECHANICAL: lootMechanical(world, x, y, z);
case LOOT_GEAR: lootMechanical(world, x, y, z);
default: lootBones(world, x, y, z); break;
}
}
@ -60,6 +64,9 @@ public class LootGenerator {
LOOT_GLYPHID_HIVE,
LOOT_METEOR,
LOOT_FLAREGUN,
LOOT_MECHANICAL,
LOOT_GEAR,
LOOT_SHIT,
};
}
@ -247,4 +254,30 @@ 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(6) + 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);
}
}
}
public static void lootGear(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(6) + 1;
for(int i = 0; i < limit; i++) {
addItemWithDeviation(loot, world.rand, ItemPool.getStack(ItemPool.getPool(ItemPoolsPile.POOL_PILE_GEAR), world.rand), world.rand.nextDouble() - 0.5, i * 0.03125, world.rand.nextDouble() - 0.5);
}
}
}
}

View File

@ -14,7 +14,11 @@ import java.util.*;
public class MobUtil {
//for soot mobs
public static Map<Integer, List<WeightedRandomObject>> slotPoolCommonS = new HashMap<>();
public static Map<Integer, List<WeightedRandomObject>> slotPoolRangedS = new HashMap<>();
//for gob block
public static Map<Integer, List<WeightedRandomObject>> slotPoolCommon = new HashMap<>();
public static Map<Integer, List<WeightedRandomObject>> slotPoolRanged = new HashMap<>();
@ -33,25 +37,26 @@ public class MobUtil {
public static Map<Integer, List<WeightedRandomObject>> slotPoolMelee = new HashMap<>();
public static void intializeMobPools(){
slotPoolCommon.put(4, createSlotPool(8000, new Object[][]{ //new slots, smooth, brushed, no wrinkles // old slots, wrinkled, rusty, not smooth
//soot mobs
slotPoolCommonS.put(4, createSlotPool(8000, new Object[][]{ //new slots, smooth, brushed, no wrinkles // old slots, wrinkled, rusty, not smooth
{ModItems.gas_mask_m65, 16}, {ModItems.gas_mask_olde, 12}, {ModItems.mask_of_infamy, 8},
{ModItems.gas_mask_mono, 8}, {ModItems.robes_helmet, 32}, {ModItems.no9, 16},
{ModItems.cobalt_helmet, 2}, {ModItems.rag_piss, 1}, {ModItems.hat, 1}, {ModItems.alloy_helmet, 2},
{ModItems.titanium_helmet, 4}, {ModItems.steel_helmet, 8}
}));
slotPoolCommon.put(3, createSlotPool(7000, new Object[][]{
slotPoolCommonS.put(3, createSlotPool(7000, new Object[][]{
{ModItems.starmetal_plate, 1}, {ModItems.cobalt_plate, 2}, {ModItems.robes_plate, 32},
{ModItems.jackt, 32}, {ModItems.jackt2, 32}, {ModItems.alloy_plate, 2},
{ModItems.steel_plate, 2}
}));
slotPoolCommon.put(2, createSlotPool(7000, new Object[][]{
slotPoolCommonS.put(2, createSlotPool(7000, new Object[][]{
{ModItems.zirconium_legs, 1}, {ModItems.cobalt_legs, 2}, {ModItems.steel_legs, 16},
{ModItems.titanium_legs, 8}, {ModItems.robes_legs, 32}, {ModItems.alloy_legs, 2}
}));
slotPoolCommon.put(1, createSlotPool(7000, new Object[][]{
slotPoolCommonS.put(1, createSlotPool(7000, new Object[][]{
{ModItems.robes_boots, 32}, {ModItems.steel_boots, 16}, {ModItems.cobalt_boots, 2}, {ModItems.alloy_boots, 2}
}));
slotPoolCommon.put(0, createSlotPool(10000, new Object[][]{
slotPoolCommonS.put(0, createSlotPool(10000, new Object[][]{
{ModItems.pipe_lead, 30}, {ModItems.crowbar, 25}, {ModItems.geiger_counter, 20},
{ModItems.reer_graar, 16}, {ModItems.steel_pickaxe, 12}, {ModItems.stopsign, 10},
{ModItems.sopsign, 8}, {ModItems.chernobylsign, 6}, {ModItems.steel_sword, 15},
@ -59,25 +64,73 @@ public class MobUtil {
{ModItems.wrench, 20}
}));
slotPoolRanged.put(4, createSlotPool(12000, new Object[][]{
slotPoolRangedS.put(4, createSlotPool(8000, new Object[][]{
{ModItems.gas_mask_m65, 16}, {ModItems.gas_mask_olde, 12}, {ModItems.mask_of_infamy, 8},
{ModItems.gas_mask_mono, 8}, {ModItems.robes_helmet, 32}, {ModItems.no9, 16},
{ModItems.rag_piss, 1}, {ModItems.goggles, 1}, {ModItems.alloy_helmet, 2},
{ModItems.titanium_helmet, 4}, {ModItems.steel_helmet, 8}
}));
slotPoolRanged.put(3, createSlotPool(10000, new Object[][]{
slotPoolRangedS.put(3, createSlotPool(7000, new Object[][]{
{ModItems.starmetal_plate, 1}, {ModItems.cobalt_plate, 2}, {ModItems.alloy_plate, 2}, //sadly they cant wear jackets bc it breaks it
{ModItems.steel_plate, 8}, {ModItems.titanium_plate, 4}
}));
slotPoolRanged.put(2, createSlotPool(10000, new Object[][]{
slotPoolRangedS.put(2, createSlotPool(7000, new Object[][]{
{ModItems.zirconium_legs, 1}, {ModItems.cobalt_legs, 2}, {ModItems.steel_legs, 16},
{ModItems.titanium_legs, 8}, {ModItems.robes_legs, 32}, {ModItems.alloy_legs, 2},
}));
slotPoolRanged.put(1, createSlotPool(10000, new Object[][]{
slotPoolRangedS.put(1, createSlotPool(10000, new Object[][]{
{ModItems.robes_boots, 32}, {ModItems.steel_boots, 16}, {ModItems.cobalt_boots, 2}, {ModItems.alloy_boots, 2},
{ModItems.titanium_boots, 6}
}));
//gob block
//soot mobs
slotPoolCommon.put(4, createSlotPool(0, new Object[][]{ //new slots, smooth, brushed, no wrinkles // old slots, wrinkled, rusty, not smooth
{ModItems.gas_mask_m65, 16}, {ModItems.gas_mask_olde, 12}, {ModItems.mask_of_infamy, 8},
{ModItems.gas_mask_mono, 8}, {ModItems.robes_helmet, 32}, {ModItems.no9, 16},
{ModItems.cobalt_helmet, 2}, {ModItems.rag_piss, 1}, {ModItems.hat, 1}, {ModItems.alloy_helmet, 2},
{ModItems.titanium_helmet, 4}, {ModItems.steel_helmet, 8}
}));
slotPoolCommon.put(3, createSlotPool(10, new Object[][]{
{ModItems.starmetal_plate, 1}, {ModItems.cobalt_plate, 2}, {ModItems.robes_plate, 32},
{ModItems.jackt, 32}, {ModItems.jackt2, 32}, {ModItems.alloy_plate, 2},
{ModItems.steel_plate, 2}
}));
slotPoolCommon.put(2, createSlotPool(20, new Object[][]{
{ModItems.zirconium_legs, 1}, {ModItems.cobalt_legs, 2}, {ModItems.steel_legs, 16},
{ModItems.titanium_legs, 8}, {ModItems.robes_legs, 32}, {ModItems.alloy_legs, 2}
}));
slotPoolCommon.put(1, createSlotPool(10, new Object[][]{
{ModItems.robes_boots, 32}, {ModItems.steel_boots, 16}, {ModItems.cobalt_boots, 2}, {ModItems.alloy_boots, 2}
}));
slotPoolCommon.put(0, createSlotPool(1000, new Object[][]{
{ModItems.pipe_lead, 30}, {ModItems.crowbar, 25}, {ModItems.geiger_counter, 20},
{ModItems.reer_graar, 16}, {ModItems.steel_pickaxe, 12}, {ModItems.stopsign, 10},
{ModItems.sopsign, 8}, {ModItems.chernobylsign, 6}, {ModItems.steel_sword, 15},
{ModItems.titanium_sword, 8}, {ModItems.lead_gavel, 4}, {ModItems.wrench_flipped, 2},
{ModItems.wrench, 20}
}));
slotPoolRanged.put(4, createSlotPool(0, new Object[][]{
{ModItems.gas_mask_m65, 16}, {ModItems.gas_mask_olde, 12}, {ModItems.mask_of_infamy, 8},
{ModItems.gas_mask_mono, 8}, {ModItems.robes_helmet, 32}, {ModItems.no9, 16},
{ModItems.rag_piss, 1}, {ModItems.goggles, 1}, {ModItems.alloy_helmet, 2},
{ModItems.titanium_helmet, 4}, {ModItems.steel_helmet, 8}
}));
slotPoolRanged.put(3, createSlotPool(10, new Object[][]{
{ModItems.starmetal_plate, 1}, {ModItems.cobalt_plate, 2}, {ModItems.alloy_plate, 2}, //sadly they cant wear jackets bc it breaks it
{ModItems.steel_plate, 8}, {ModItems.titanium_plate, 4}
}));
slotPoolRanged.put(2, createSlotPool(10, new Object[][]{
{ModItems.zirconium_legs, 1}, {ModItems.cobalt_legs, 2}, {ModItems.steel_legs, 16},
{ModItems.titanium_legs, 8}, {ModItems.robes_legs, 32}, {ModItems.alloy_legs, 2},
}));
slotPoolRanged.put(1, createSlotPool(10, new Object[][]{
{ModItems.robes_boots, 32}, {ModItems.steel_boots, 16}, {ModItems.cobalt_boots, 2}, {ModItems.alloy_boots, 2},
{ModItems.titanium_boots, 6}
}));
//soot guns
slotPoolGuns.put(0.3, createSlotPool(new Object[][]{
{ModItems.gun_light_revolver, 16}, {ModItems.gun_greasegun, 8}, {ModItems.gun_maresleg, 2}
}));
@ -111,9 +164,9 @@ public class MobUtil {
{ModItems.t51_boots, 4}, {ModItems.hazmat_boots, 6},
{ModItems.robes_boots, 8}
}));
slotPoolAdv.put(0, createSlotPool(new Object[][]{
{ModItems.pipe_lead, 20}, {ModItems.crowbar, 30}, {ModItems.geiger_counter, 20},
{ModItems.reer_graar, 20}, {ModItems.wrench_flipped, 12}, {ModItems.stopsign, 16},
slotPoolAdv.put(0, createSlotPool(500,new Object[][]{
{ModItems.pipe_lead, 20}, {ModItems.crowbar, 10}, {ModItems.geiger_counter, 10},
{ModItems.reer_graar, 20}, {ModItems.wrench_flipped, 20}, {ModItems.stopsign, 16},
{ModItems.sopsign, 4}, {ModItems.chernobylsign, 16},
{ModItems.titanium_sword, 18}, {ModItems.lead_gavel, 8},
{ModItems.wrench, 20}
@ -121,68 +174,15 @@ public class MobUtil {
//For action block
slotPoolGunsTier1.put(0, createSlotPool(0, new Object[][]{
{ModItems.gun_light_revolver, 16}, {ModItems.gun_greasegun, 8}, {ModItems.gun_maresleg, 2}
{ModItems.gun_light_revolver, 16}, {ModItems.gun_greasegun, 8}, {ModItems.gun_maresleg, 2}, {ModItems.gun_flaregun, 1}
}));
slotPoolGunsTier2.put(0, createSlotPool(0, new Object[][]{
{ModItems.gun_uzi, 10}, {ModItems.gun_maresleg, 8}, {ModItems.gun_henry, 12}, {ModItems.gun_heavy_revolver, 4}, {ModItems.gun_flaregun, 4}, {ModItems.gun_carbine, 4}
{ModItems.gun_uzi, 12}, {ModItems.gun_maresleg, 8}, {ModItems.gun_henry, 12}, {ModItems.gun_heavy_revolver, 8}, {ModItems.gun_flaregun, 4}, {ModItems.gun_star_f, 8}
}));
slotPoolGunsTier3.put(0, createSlotPool(0, new Object[][]{
{ModItems.gun_uzi, 25}, {ModItems.gun_spas12, 20}, {ModItems.gun_carbine, 20}, {ModItems.gun_g3, 10}, {ModItems.gun_am180, 5}, {ModItems.gun_stg77, 5}
}));
slotPoolMasks.put(4, createSlotPool(0, new Object[][]{
{ModItems.gas_mask_m65, 16}, {ModItems.gas_mask_mono, 8}, {ModItems.robes_helmet, 32}, {ModItems.no9, 16},
{ModItems.rag_piss, 4}, {ModItems.goggles, 12}
}));
slotPoolHelms.put(4, createSlotPool(0, new Object[][]{
{ModItems.gas_mask_m65, 16}, {ModItems.gas_mask_olde, 12}, {ModItems.mask_of_infamy, 8},
{ModItems.gas_mask_mono, 8}, {ModItems.robes_helmet, 32}, {ModItems.no9, 16},
{ModItems.cobalt_helmet, 2}, {ModItems.hat, 1}, {ModItems.alloy_helmet, 2},
{ModItems.titanium_helmet, 4}, {ModItems.steel_helmet, 8}
}));
slotPoolTierArmor.put(4, createSlotPool(new Object[][]{
{ModItems.gas_mask_m65, 20},
{ModItems.gas_mask_olde, 15},
{ModItems.steel_helmet, 25},
{ModItems.titanium_helmet, 15},
{ModItems.alloy_helmet, 10},
}));
slotPoolTierArmor.put(3, createSlotPool(new Object[][]{
{ModItems.steel_plate, 30},
{ModItems.titanium_plate, 20},
{ModItems.alloy_plate, 15},
{ModItems.cobalt_plate, 5},
{ModItems.starmetal_plate, 5}
}));
slotPoolTierArmor.put(2, createSlotPool(new Object[][]{
{ModItems.steel_legs, 30},
{ModItems.titanium_legs, 20},
{ModItems.alloy_legs, 15},
{ModItems.cobalt_legs, 5},
{ModItems.zirconium_legs, 5}
}));
slotPoolTierArmor.put(1, createSlotPool(new Object[][]{
{ModItems.steel_boots, 30},
{ModItems.robes_boots, 25},
{ModItems.titanium_boots, 20},
{ModItems.alloy_boots, 15},
{ModItems.hazmat_boots, 10},
{ModItems.cobalt_boots, 5},
}));
slotPoolMelee.put(0, createSlotPool(2000, new Object[][]{
{ModItems.pipe_lead, 40}, {ModItems.crowbar, 35}, {ModItems.wrench, 30},
{ModItems.steel_sword, 25}, {ModItems.titanium_sword, 20},
{ModItems.reer_graar, 20}, {ModItems.stopsign, 15},
{ModItems.lead_gavel, 12}, {ModItems.wrench_flipped, 10},
{ModItems.sopsign, 8}, {ModItems.chernobylsign, 8}
{ModItems.gun_g3, 25}, {ModItems.gun_spas12, 20}, {ModItems.gun_carbine, 15}, {ModItems.gun_star_f, 20}, {ModItems.gun_am180, 6}, {ModItems.gun_amat, 5}
}));
slotPoolAdvRanged = new HashMap<>(slotPoolAdv);
@ -268,4 +268,15 @@ public class MobUtil {
entity.tasks.addTask(3, new EntityAIFireGun(entity));
}
public static void addFireTask(EntityLiving entity, EntityAIFireGun gunTask) {
entity.setEquipmentDropChance(0, 0); // Prevent dropping guns
for(Object entry : entity.tasks.taskEntries) {
EntityAITasks.EntityAITaskEntry task = (EntityAITasks.EntityAITaskEntry) entry;
if(task.action instanceof EntityAIFireGun) return;
}
entity.tasks.addTask(3, gunTask);
}
}

View File

@ -9,6 +9,7 @@ import java.io.InputStream;
import java.util.*;
import java.util.function.Predicate;
import com.hbm.config.ServerConfig;
import org.apache.commons.io.IOUtils;
import com.hbm.blocks.ModBlocks;
@ -80,7 +81,7 @@ public class NBTStructure {
private Map<String, List<JigsawConnection>> toTopConnections;
private Map<String, List<JigsawConnection>> toBottomConnections;
private Map<String, List<JigsawConnection>> toHorizontalConnections;
// incredibly shitty system for translating legacy block definitions to new ones
@Untested // i can't find a god damn factory
private static Map<String, String> substitutions = new HashMap() {{
@ -328,7 +329,7 @@ public class NBTStructure {
String blockName = p.getString("Name");
NBTTagCompound prop = p.getCompoundTag("Properties");
/// BOB PATCH ///
if(substitutions.containsKey(blockName)) blockName = substitutions.get(blockName);
/// BOB PATCH ///
@ -343,7 +344,7 @@ public class NBTStructure {
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);
}
}
@ -416,7 +417,7 @@ public class NBTStructure {
List<JigsawConnection> namedConnections = toConnections.computeIfAbsent(ourName, name -> new ArrayList<>());
namedConnections.add(connection);
if(!StructureConfig.debugStructures) {
if(!ServerConfig.STRUCTURE_DEBUG.get()) {
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.Predicate;
import com.hbm.config.ServerConfig;
import com.hbm.config.StructureConfig;
import com.hbm.util.Tuple.Pair;
import com.hbm.util.Tuple.Quartet;
@ -109,7 +110,7 @@ public class SpawnCondition {
// Make sure structure debug is enabled, or it will no-op
// Do not use in generation
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 oz = 0;
@ -148,4 +149,4 @@ public class SpawnCondition {
}
}
}

View File

@ -7,9 +7,12 @@ import com.hbm.blocks.generic.LogicBlock;
import com.hbm.entity.item.EntityFallingBlockNT;
import com.hbm.entity.missile.EntityMissileTier2;
import com.hbm.entity.mob.EntityUndeadSoldier;
import com.hbm.entity.mob.ai.EntityAIFireGun;
import com.hbm.items.ItemEnums;
import com.hbm.items.ModItems;
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.util.ContaminationUtil;
import com.hbm.util.MobUtil;
@ -20,6 +23,7 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
@ -33,7 +37,7 @@ import java.util.function.Consumer;
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) -> {
World world = tile.getWorldObj();
@ -169,81 +173,103 @@ 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();
int x = tile.xCoord;
int y = tile.yCoord;
int z = tile.zCoord;
if (tile.phase == 1) {
EntitySkeleton mob = new EntitySkeleton(world);
mob.setPositionAndRotation(x, y, z, 0, 0);
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolGunsTier1, new Random());
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolMasks, new Random());
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolRanged, new Random());
world.spawnEntityInWorld(mob);
world.setBlock(x, y, z, Blocks.air);
for (int i = 0; i < 3; i++) {
EntitySkeleton mob = new EntitySkeleton(world);
mob.setPositionAndRotation(x, y, z, 0, 0);
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolGunsTier1, new Random());
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolMasks, new Random());
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolRanged, new Random());
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();
int x = tile.xCoord;
int y = tile.yCoord;
int z = tile.zCoord;
if (tile.phase == 1) {
EntitySkeleton mob = new EntitySkeleton(world);
mob.setPositionAndRotation(x, y, z, 0, 0);
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolGunsTier2, new Random());
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolMasks, new Random());
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolTierArmor, new Random());
world.spawnEntityInWorld(mob);
world.setBlock(x, y, z, Blocks.air);
for (int i = 0; i < 3; i++) {
EntitySkeleton mob = new EntitySkeleton(world);
mob.setPositionAndRotation(x, y, z, 0, 0);
EntityAIFireGun gunTask = new EntityAIFireGun(mob);
gunTask.minWait = 4;
gunTask.maxWait = 5;
gunTask.maxRange = 50;
gunTask.burstTime = 6;
gunTask.inaccuracy = 5F;
gunTask.randomBurst = false;
MobUtil.addFireTask(mob, gunTask);
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolGunsTier2, new Random());
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolRanged, new Random());
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();
int x = tile.xCoord;
int y = tile.yCoord;
int z = tile.zCoord;
if (tile.phase == 1) {
EntitySkeleton mob = new EntitySkeleton(world);
mob.setPositionAndRotation(x, y, z, 0, 0);
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolGunsTier3, new Random());
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolMasks, new Random());
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolAdvRanged, new Random());
world.spawnEntityInWorld(mob);
world.setBlock(x, y, z, Blocks.air);
for (int i = 0; i < 3; i++) {
EntitySkeleton mob = new EntitySkeleton(world);
mob.setPositionAndRotation(x, y, z, 0, 0);
EntityAIFireGun gunTask = new EntityAIFireGun(mob);
gunTask.minWait = 4;
gunTask.maxWait = 5;
gunTask.maxRange = 100;
gunTask.burstTime = 6;
gunTask.inaccuracy = 1F;
gunTask.randomBurst = false;
MobUtil.addFireTask(mob, gunTask);
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolGunsTier3, new Random());
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolAdvRanged, new Random());
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();
int x = tile.xCoord;
int y = tile.yCoord;
int z = tile.zCoord;
if (tile.phase == 1) {
EntityZombie mob = new EntityZombie(world);
mob.setPositionAndRotation(x, y, z, 0, 0);
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolMelee, new Random());
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolTierArmor, new Random());
world.spawnEntityInWorld(mob);
world.setBlock(x, y, z, Blocks.air);
for (int i = 0; i < 3; i++) {
EntityZombie mob = new EntityZombie(world);
mob.setPositionAndRotation(x, y, z, 0, 0);
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolCommon, new Random());
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();
int x = tile.xCoord;
int y = tile.yCoord;
int z = tile.zCoord;
if (tile.phase == 1) {
EntityZombie mob = new EntityZombie(world);
mob.setPositionAndRotation(x, y, z, 0, 0);
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolTierArmor, new Random());
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolMelee, new Random());
world.spawnEntityInWorld(mob);
world.setBlock(x, y, z, Blocks.air);
for (int i = 0; i < 3; i++) {
EntityZombie mob = new EntityZombie(world);
mob.setPositionAndRotation(x, y, z, 0, 0);
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolAdv, new Random());
world.spawnEntityInWorld(mob);
world.setBlock(x, y, z, Blocks.air);
}
}
};
@ -361,28 +387,139 @@ 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;
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;
for (int i1 = 0; i1 < 6; ++i1) {
if (world.getTileEntity(x + Facing.offsetsXForSide[i1], y + Facing.offsetsYForSide[i1], z + Facing.offsetsZForSide[i1]) instanceof TileEntityLockableBase) {
safe = (TileEntityLockableBase) world.getTileEntity(x + Facing.offsetsXForSide[i1], y + Facing.offsetsYForSide[i1], z + Facing.offsetsZForSide[i1]);
break;
}
}
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;
if(tile.phase == 0) {
world.setBlock(x, y + 1, z, ModBlocks.charge_c4, ForgeDirection.UP.ordinal(), 3);
TileEntity te = world.getTileEntity(x, y + 1, z);
if (te instanceof TileEntityCharge) {
TileEntityCharge bomb = (TileEntityCharge) te;
bomb.timer = 1200;
}
}
if(tile.phase >= 1) {
TileEntity te = world.getTileEntity(x, y + 1, z);
if (te instanceof TileEntityCharge) {
TileEntityCharge bomb = (TileEntityCharge) te;
bomb.started = true;
}
world.setBlock(x, y, z, ModBlocks.block_steel);
}
};
public static Consumer<LogicBlock.TileEntityLogicBlock> DEAD_GUY_CRANE = (tile) -> {
World world = tile.getWorldObj();
int x = tile.xCoord;
int y = tile.yCoord;
int z = tile.zCoord;
if(tile.phase == 1) {
world.setBlock(x, y, z, ModBlocks.skeleton_holder);
TileEntity te = world.getTileEntity(x, y, z);
EntityPlayer player = (EntityPlayer) world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y - 2, z + 1).expand(25, 25, 25)).get(0);
if (te instanceof BlockSkeletonHolder.TileEntitySkeletonHolder) {
BlockSkeletonHolder.TileEntitySkeletonHolder skeleton = (BlockSkeletonHolder.TileEntitySkeletonHolder) te;
if (player != null && player.inventory.hasItem(ModItems.gun_hangman)) {
skeleton.item = new ItemStack(ModItems.clay_tablet, 1, 0);
} else {
skeleton.item = new ItemStack(ModItems.gun_hangman);
}
skeleton.markDirty();
world.markBlockForUpdate(x, y, z);
}
}
};
public static List<String> getActionNames(){
return new ArrayList<>(actions.keySet());
}
//register new actions here
static{
//example actions
initialize();
}
public static void initialize(){
actions = new LinkedHashMap<>();
//logic actions
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_10", COLLAPSE_ROOF_RAD_10);
actions.put("BOMB_TRAP", BOMB_TRAP);
actions.put("BOMB_CRANE", BOMB_CRANE);
actions.put("DEAD_GUY_CRANE", DEAD_GUY_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("MISSILE_STRIKE", MISSILE_STRIKE);
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,12 +5,15 @@ import com.hbm.blocks.generic.BlockPedestal;
import com.hbm.blocks.generic.LogicBlock;
import com.hbm.entity.mob.EntityUndeadSoldier;
import com.hbm.items.ModItems;
import com.hbm.tileentity.bomb.TileEntityCharge;
import com.hbm.tileentity.machine.TileEntityLockableBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.ArrayList;
import java.util.LinkedHashMap;
@ -19,7 +22,7 @@ import java.util.function.Function;
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*/
public static Function<LogicBlock.TileEntityLogicBlock, Boolean> EMPTY = (tile) -> false;
@ -96,18 +99,49 @@ public class LogicBlockConditions {
&& ((BlockPedestal.TileEntityPedestal) pedestal).item.getItem() == ModItems.big_sword;
};
public static Function<LogicBlock.TileEntityLogicBlock, Boolean> BOMB_CRANE = (tile) -> {
World world = tile.getWorldObj();
int x = tile.xCoord;
int y = tile.yCoord;
int z = tile.zCoord;
if(tile.phase == 0) {
world.setBlock(x, y + 1, z, ModBlocks.charge_c4, ForgeDirection.UP.ordinal(), 3);
TileEntity te = world.getTileEntity(x, y + 1, z);
if (te instanceof TileEntityCharge) {
TileEntityCharge bomb = (TileEntityCharge) te;
bomb.timer = 200;
}
}
return !world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y - 2, z + 1).expand(10, 10, 10)).isEmpty();
};
public static List<String> getConditionNames(){
return new ArrayList<>(conditions.keySet());
}
//register new conditions here
static {
//example conditions
initialize();
}
public static void initialize() {
conditions = new LinkedHashMap<>();
conditions.put("EMPTY", EMPTY);
conditions.put("ABERRATOR", ABERRATOR);
conditions.put("PLAYER_CUBE_3", PLAYER_CUBE_3);
conditions.put("PLAYER_CUBE_5", PLAYER_CUBE_5);
conditions.put("PLAYER_CUBE_25", PLAYER_CUBE_25);
conditions.put("BOMB_CRANE", BOMB_CRANE);
//example conditions
conditions.put("ABERRATOR", ABERRATOR);
conditions.put("REDSTONE", REDSTONE);
conditions.put("PUZZLE_TEST", PUZZLE_TEST);
}

View File

@ -1,12 +1,19 @@
package com.hbm.world.gen.util;
import api.hbm.energymk2.IEnergyHandlerMK2;
import com.hbm.blocks.generic.LogicBlock;
import com.hbm.items.ModItems;
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.potion.PotionEffect;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.Facing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.ArrayList;
import java.util.LinkedHashMap;
@ -18,11 +25,16 @@ public class LogicBlockInteractions {
/**Consumer consists of world instance, tile entity instance, three ints for coordinates, one int for block side, and player instance,
* 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) -> {
World world = (World) array[0];
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];
int side = (int) array[6];
if(logic.phase > 1) return;
@ -48,6 +60,49 @@ 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);
for (int i1 = 0; i1 < 6; ++i1) {
if(world.getTileEntity(x + Facing.offsetsXForSide[i1], y + Facing.offsetsYForSide[i1], z + Facing.offsetsZForSide[i1]) instanceof IEnergyHandlerMK2) {
handler = (IEnergyHandlerMK2) world.getTileEntity(x + Facing.offsetsXForSide[i1], y + Facing.offsetsYForSide[i1], z + Facing.offsetsZForSide[i1]);
break;
}
}
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;
for (int i1 = 0; i1 < 6; ++i1) {
if (world.getTileEntity(x + Facing.offsetsXForSide[i1], y + Facing.offsetsYForSide[i1], z + Facing.offsetsZForSide[i1]) instanceof TileEntityLockableBase) {
safe = (TileEntityLockableBase) world.getTileEntity(x + Facing.offsetsXForSide[i1], y + Facing.offsetsYForSide[i1], z + Facing.offsetsZForSide[i1]);
break;
}
}
if(safe != null){
safe.unlock();
world.playSoundAtEntity(player, "hbm:block.lockOpen", 3.0F, 0.8F);
}
}
};
public static List<String> getInteractionNames(){
@ -56,6 +111,14 @@ public class LogicBlockInteractions {
//register new interactions here
static{
initialize();
}
public static void initialize() {
interactions = new LinkedHashMap<>();
interactions.put("POWER_LOCK", POWER_LOCK);
//example interactions
interactions.put("TEST", TEST);
interactions.put("RADAWAY_INJECTOR", RAD_CONTAINMENT_SYSTEM);
}

View File

@ -5447,6 +5447,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.falloffOn=Fan power decreases with distance
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_post.name=Chainlink Fence Post
tile.field_disturber.name=High Energy Field Jammer

Binary file not shown.