the gob block

This commit is contained in:
70000hp 2025-06-29 19:11:39 -04:00
parent 3583ad66cd
commit 3db1dbd277
12 changed files with 760 additions and 199 deletions

View File

@ -1240,6 +1240,7 @@ public class ModBlocks {
public static Block wand_air;
public static Block wand_loot;
public static Block wand_jigsaw;
public static Block wand_spawner;
public static Material materialGas = new MaterialGas();
@ -2390,6 +2391,8 @@ public class ModBlocks {
wand_air = new BlockWand(Blocks.air).setBlockName("wand_air").setBlockTextureName(RefStrings.MODID + ":wand_air");
wand_loot = new BlockWandLoot().setBlockName("wand_loot").setBlockTextureName(RefStrings.MODID + ":wand_loot");
wand_jigsaw = new BlockWandJigsaw().setBlockName("wand_jigsaw").setBlockTextureName(RefStrings.MODID + ":wand_jigsaw");
wand_spawner = new BlockWandSpawner().setBlockName("wand_spawner").setBlockTextureName(RefStrings.MODID + ":wand_spawner");
}
private static void registerBlock() {
@ -3534,6 +3537,7 @@ public class ModBlocks {
register(wand_air);
register(wand_loot);
register(wand_jigsaw);
register(wand_spawner);
}
private static void register(Block b) {

View File

@ -0,0 +1,249 @@
package com.hbm.blocks.generic;
import api.hbm.block.IToolable;
import com.hbm.blocks.IBlockSideRotation;
import com.hbm.blocks.ILookOverlay;
import com.hbm.blocks.ITooltipProvider;
import com.hbm.blocks.ModBlocks;
import com.hbm.config.StructureConfig;
import com.hbm.interfaces.IBomb;
import com.hbm.interfaces.ICopiable;
import com.hbm.lib.RefStrings;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.TileEntityLoadedBase;
import com.hbm.util.BufferUtil;
import com.hbm.util.i18n.I18nUtil;
import com.hbm.world.gen.INBTTileEntityTransformable;
import com.hbm.world.gen.util.DungeonSpawnerActions;
import com.hbm.world.gen.util.DungeonSpawnerConditions;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import java.util.ArrayList;
import java.util.List;
public class BlockWandSpawner extends BlockContainer implements ILookOverlay, IToolable, ITooltipProvider, IBlockSideRotation, IBomb {
@SideOnly(Side.CLIENT) protected IIcon iconTop;
public BlockWandSpawner() {
super(Material.iron);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":wand_spawner");
this.iconTop = iconRegister.registerIcon(RefStrings.MODID + ":wand_spawner_top");
}
@Override
public IIcon getIcon(int side, int meta) {
return (side <= 1) ? iconTop : blockIcon;
}
@Override
public int getRotationFromSide(IBlockAccess world, int x, int y, int z, int side) {
if(side == 0) return IBlockSideRotation.topToBottom(world.getBlockMetadata(x, y, z));
if(side == 1) return world.getBlockMetadata(x, y, z);
return 0;
}
@Override
public int getRenderType() {
return IBlockSideRotation.getRenderType();
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {
int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
if (i == 0) world.setBlockMetadataWithNotify(x, y, z, 3, 2);
if (i == 1) world.setBlockMetadataWithNotify(x, y, z, 2, 2);
if (i == 2) world.setBlockMetadataWithNotify(x, y, z, 0, 2);
if (i == 3) world.setBlockMetadataWithNotify(x, y, z, 1, 2);
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileEntityWandSpawner)
((TileEntityWandSpawner)te).placedRotation = i;
}
@Override
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {
TileEntity te = world.getTileEntity(x, y, z);
if(!(te instanceof TileEntityWandSpawner)) return false;
TileEntityWandSpawner spawner = (TileEntityWandSpawner) te;
switch(tool) {
case SCREWDRIVER:
List<String> actionNames = DungeonSpawnerActions.getActionNames();
int indexA = actionNames.indexOf(spawner.actionID);
indexA += player.isSneaking() ? -1 : 1;
indexA = MathHelper.clamp_int(indexA, 0, actionNames.size() - 1);
spawner.actionID = actionNames.get(indexA);
return true;
case DEFUSER:
List<String> conditionNames = DungeonSpawnerConditions.getConditionNames();
int indexC = conditionNames.indexOf(spawner.conditionID);
indexC += player.isSneaking() ? -1 : 1;
indexC = MathHelper.clamp_int(indexC, 0, conditionNames.size() - 1);
spawner.conditionID = conditionNames.get(indexC);
return true;
default: return false;
}
}
@Override
public void printHook(RenderGameOverlayEvent.Pre event, World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
if(!(te instanceof TileEntityWandSpawner)) return;
TileEntityWandSpawner spawner = (TileEntityWandSpawner) te;
List<String> text = new ArrayList<String>();
text.add("Action: " + spawner.actionID);
text.add("Condition: " + spawner.conditionID);
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
list.add(EnumChatFormatting.GOLD + "Use screwdriver to cycle forwards through the action list, shift click to go back");
list.add(EnumChatFormatting.GOLD + "Use defuser to cycle forwards through the condition list, shift click to go back");
list.add(EnumChatFormatting.BLUE + "Use a detonator to transform");
}
@Override
public TileEntity createNewTileEntity(World worldIn, int meta) {
return new TileEntityWandSpawner();
}
@Override
public BombReturnCode explode(World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
if(!(te instanceof TileEntityWandSpawner)) return null;
((TileEntityWandSpawner) te).triggerReplace = true;
return BombReturnCode.TRIGGERED;
}
public static class TileEntityWandSpawner extends TileEntityLoadedBase implements INBTTileEntityTransformable, ICopiable {
private boolean triggerReplace;
public int placedRotation;
public String actionID = "PHASE_ABERRATOR";
public String conditionID = "ABERRATOR";
@Override
public void updateEntity() {
if(!worldObj.isRemote) {
if(triggerReplace) {
// On the first tick of this TE, replace with intended block and fill with loot
replace();
} else {
networkPackNT(15);
}
}
}
private void replace() {
if (!(worldObj.getBlock(xCoord, yCoord, zCoord) instanceof BlockWandSpawner)) {
MainRegistry.logger.warn("Somehow the block at: " + xCoord + ", " + yCoord + ", " + zCoord + " isn't a dungeon spawner block but we're doing a TE update as if it is, cancelling!");
return;
}
worldObj.setBlock(xCoord,yCoord,zCoord, ModBlocks.dungeon_spawner);
TileEntity te = worldObj.getTileEntity(xCoord, yCoord, zCoord);
if(te == null || te instanceof BlockWandLoot.TileEntityWandLoot) {
MainRegistry.logger.warn("TE for dungeon spawner set incorrectly at: " + xCoord + ", " + yCoord + ", " + zCoord + ". If you're using some sort of world generation mod, report it to the author!");
te = ModBlocks.wand_spawner.createTileEntity(worldObj, 0);
worldObj.setTileEntity(xCoord, yCoord, zCoord, te);
}
if(te instanceof DungeonSpawner.TileEntityDungeonSpawner){
DungeonSpawner.TileEntityDungeonSpawner spawner = (DungeonSpawner.TileEntityDungeonSpawner) te;
spawner.actionID = actionID;
spawner.conditionID = conditionID;
}
}
@Override
public void transformTE(World world, int coordBaseMode) {
triggerReplace = !StructureConfig.debugStructures;
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setString("actionID", actionID);
nbt.setString("conditionID", conditionID);
nbt.setInteger("rotation", placedRotation);
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
actionID = nbt.getString("actionID");
conditionID = nbt.getString("conditionID");
placedRotation = nbt.getInteger("rotation");
}
@Override
public void serialize(ByteBuf buf) {
buf.writeInt(placedRotation);
BufferUtil.writeString(buf, actionID);
BufferUtil.writeString(buf, conditionID);
}
@Override
public void deserialize(ByteBuf buf) {
placedRotation = buf.readInt();
actionID = BufferUtil.readString(buf);
conditionID = BufferUtil.readString(buf);
}
@Override
public NBTTagCompound getSettings(World world, int x, int y, int z) {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setString("actionID", actionID);
nbt.setString("conditionID", conditionID);
return nbt;
}
@Override
public void pasteSettings(NBTTagCompound nbt, int index, World world, EntityPlayer player, int x, int y, int z) {
actionID = nbt.getString("actionID");
conditionID = nbt.getString("conditionID");
}
}
}

View File

@ -7,7 +7,8 @@ import com.hbm.blocks.generic.BlockSkeletonHolder.TileEntitySkeletonHolder;
import com.hbm.entity.mob.EntityUndeadSoldier;
import com.hbm.items.ItemEnums.EnumSecretType;
import com.hbm.items.ModItems;
import com.hbm.util.EnumUtil;
import com.hbm.world.gen.util.DungeonSpawnerActions;
import com.hbm.world.gen.util.DungeonSpawnerConditions;
import com.hbm.util.Vec3NT;
import net.minecraft.block.BlockContainer;
@ -30,19 +31,35 @@ public class DungeonSpawner extends BlockContainer {
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityDungeonSpawner();
}
public static class TileEntityDungeonSpawner extends TileEntity {
public int phase = 0;
public int timer = 0;
public EnumSpawnerType type = EnumSpawnerType.ABERRATOR;
public String conditionID = "ABERRATOR";
//actions always get called before conditions, use the phase timer in order to control behavior via condition
public String actionID = "ABERRATOR";
public Function<TileEntityDungeonSpawner, Boolean> condition;
public Consumer<TileEntityDungeonSpawner> action;
@Override
public void updateEntity() {
if(!worldObj.isRemote) {
type.phase.accept(this);
if(type.phaseCondition.apply(this)) {
if(action == null){
action = DungeonSpawnerActions.actions.get(actionID);
}
if(condition == null){
condition = DungeonSpawnerConditions.conditions.get(conditionID);
}
if(action == null || condition == null){
worldObj.setBlock(xCoord,yCoord,zCoord, Blocks.air);
return;
}
action.accept(this);
if(condition.apply(this)) {
phase++;
timer = 0;
} else {
@ -55,83 +72,16 @@ public class DungeonSpawner extends BlockContainer {
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setInteger("phase", phase);
nbt.setByte("type", (byte) type.ordinal());
nbt.setString("conditionID", conditionID);
nbt.setString("actionID", actionID);
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.phase = nbt.getInteger("phase");
this.type = EnumUtil.grabEnumSafely(EnumSpawnerType.class, nbt.getByte("type"));
this.conditionID = nbt.getString("conditionID");
}
}
public static enum EnumSpawnerType {
ABERRATOR(CON_ABERRATOR, PHASE_ABERRATOR);
public Function<TileEntityDungeonSpawner, Boolean> phaseCondition;
public Consumer<TileEntityDungeonSpawner> phase;
private EnumSpawnerType(Function<TileEntityDungeonSpawner, Boolean> con, Consumer<TileEntityDungeonSpawner> ph) {
this.phaseCondition = con;
this.phase = ph;
}
}
public static Function<TileEntityDungeonSpawner, Boolean> CON_ABERRATOR = (tile) -> {
World world = tile.getWorldObj();
if(world.difficultySetting.ordinal() == 0) return false;
int x = tile.xCoord;
int y = tile.yCoord;
int z = tile.zCoord;
if(tile.phase == 0) {
if(world.getTotalWorldTime() % 20 != 0) return false;
return !world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y - 2, z + 1).expand(20, 10, 20)).isEmpty();
}
if(tile.phase < 3) {
if(world.getTotalWorldTime() % 20 != 0 || tile.timer < 60) return false;
return world.getEntitiesWithinAABB(EntityUndeadSoldier.class, AxisAlignedBB.getBoundingBox(x, y, z, x - 2, y + 1, z + 1).expand(50, 20, 50)).isEmpty();
}
return false;
};
public static Consumer<TileEntityDungeonSpawner> PHASE_ABERRATOR = (tile) -> {
World world = tile.getWorldObj();
int x = tile.xCoord;
int y = tile.yCoord;
int z = tile.zCoord;
if(tile.phase == 1 || tile.phase == 2) {
if(tile.timer == 0) {
Vec3NT vec = new Vec3NT(10, 0, 0);
for(int i = 0; i < 10; i++) {
EntityUndeadSoldier mob = new EntityUndeadSoldier(world);
for(int j = 0; j < 7; j++) {
mob.setPositionAndRotation(x + 0.5 + vec.xCoord, y - 5, z + 0.5 + vec.zCoord, i * 36F, 0);
if(mob.getCanSpawnHere()) {
mob.onSpawnWithEgg(null);
world.spawnEntityInWorld(mob);
break;
}
}
vec.rotateAroundYDeg(36D);
}
}
}
if(tile.phase > 2) {
TileEntity te = world.getTileEntity(x, y + 18, z);
if(te instanceof TileEntitySkeletonHolder) {
TileEntitySkeletonHolder skeleton = (TileEntitySkeletonHolder) te;
if(world.rand.nextInt(5) == 0) {
skeleton.item = new ItemStack(ModItems.item_secret, 1, EnumSecretType.ABERRATOR.ordinal());
} else {
skeleton.item = new ItemStack(ModItems.clay_tablet, 1, 1);
}
skeleton.markDirty();
world.markBlockForUpdate(x, y + 18, z);
}
world.setBlock(x, y, z, Blocks.obsidian);
}
};
}

View File

@ -877,6 +877,8 @@ public class MainRegistry {
BlockToolConversion.registerRecipes();
AchievementHandler.register();
MobUtil.intializeMobPools();
proxy.registerMissileItems();
// Load compatibility for OC.

View File

@ -387,74 +387,18 @@ public class ModEventHandler {
if(entity instanceof EntityZombie) {
if(world.rand.nextFloat() < 0.005F && soot > 2) { // full hazmat zombine
equipFullSet(entity, ModItems.hazmat_helmet, ModItems.hazmat_plate, ModItems.hazmat_legs, ModItems.hazmat_boots);
MobUtil.equipFullSet(entity, ModItems.hazmat_helmet, ModItems.hazmat_plate, ModItems.hazmat_legs, ModItems.hazmat_boots);
return;
}
if(world.rand.nextFloat() < 0.005F && soot > 20) { // full security zombine
equipFullSet(entity, ModItems.security_helmet, ModItems.security_plate, ModItems.security_legs, ModItems.security_boots);
return;
}
slotPools.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}
}));
slotPools.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}
}));
slotPools.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}
}));
slotPools.put(1, createSlotPool(7000, new Object[][]{
{ModItems.robes_boots, 32}, {ModItems.steel_boots, 16}, {ModItems.cobalt_boots, 2}, {ModItems.alloy_boots, 2}
}));
slotPools.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},
{ModItems.alloy_axe, 5}, {ModItems.titanium_sword, 8}, {ModItems.lead_gavel, 4},
{ModItems.wrench, 20}, {ModItems.cobalt_decorated_sword, 2}, {ModItems.detonator_de, 1}
}));
slotPools = MobUtil.slotPoolCommon;
} else if(entity instanceof EntitySkeleton) {
slotPools.put(4, createSlotPool(12000, 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.rag_piss, 1}, {ModItems.hat, 1}, {ModItems.alloy_helmet, 2},
{ModItems.titanium_helmet, 4}, {ModItems.steel_helmet, 8}
}));
slotPools.put(3, createSlotPool(10000, 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}
}));
slotPools.put(2, createSlotPool(10000, 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},
}));
slotPools.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}
}));
slotPools = MobUtil.slotPoolRanged;
ItemStack bowReplacement = getSkelegun(soot, world.rand);
slotPools.put(0, createSlotPool(50, bowReplacement != null ? new Object[][]{{bowReplacement, 1}} : new Object[][]{}));
}
assignItemsToEntity(entity, slotPools);
}
private void equipFullSet(EntityLivingBase entity, Item helmet, Item chest, Item legs, Item boots) { //for brainlets (me) to add more armorsets later when i forget about how this works
entity.setCurrentItemOrArmor(4, new ItemStack(helmet)); //p_70062_1_ is the slot number
entity.setCurrentItemOrArmor(3, new ItemStack(chest));
entity.setCurrentItemOrArmor(2, new ItemStack(legs));
entity.setCurrentItemOrArmor(1, new ItemStack(boots));
MobUtil.assignItemsToEntity(entity, slotPools, rand);
}
private List<WeightedRandomObject> createSlotPool(int nullWeight, Object[][] items) {
@ -473,74 +417,30 @@ public class ModEventHandler {
return pool;
}
public void assignItemsToEntity(EntityLivingBase entity, Map<Integer, List<WeightedRandomObject>> slotPools) {
for (Map.Entry<Integer, List<WeightedRandomObject>> entry : slotPools.entrySet()) {
int slot = entry.getKey();
List<WeightedRandomObject> pool = entry.getValue();
WeightedRandomObject choice = (WeightedRandomObject) WeightedRandom.getRandomItem(rand, pool); //NullPointerException sludge fix
if (choice == null) {
continue;
}
ItemStack stack = choice.asStack();
if (stack == null || stack.getItem() == null) {
continue;
}
if (stack.getItem() == ModItems.gas_mask_m65 //eyesore
|| stack.getItem() == ModItems.gas_mask_olde
|| stack.getItem() == ModItems.gas_mask_mono) {
ArmorUtil.installGasMaskFilter(stack, new ItemStack(ModItems.gas_mask_filter));
}
entity.setCurrentItemOrArmor(slot, stack);
//Give skeleton AI if it has a gun
if (slot == 0 && entity instanceof EntitySkeleton && pool == slotPools.get(0)) {
addFireTask((EntityLiving) entity);
}
}
}
private static ItemStack getSkelegun(float soot, Random rand) {
if(!MobConfig.enableMobWeapons) return null;
if(rand.nextDouble() > Math.log(soot) * 0.25) return null;
if (!MobConfig.enableMobWeapons) return null;
if (rand.nextDouble() > Math.log(soot) * 0.25) return null;
ArrayList<WeightedRandomObject> pool = new ArrayList<WeightedRandomObject>();
pool.add(new WeightedRandomObject(new ItemStack(ModItems.gun_light_revolver), 12));
pool.add(new WeightedRandomObject(new ItemStack(ModItems.gun_heavy_revolver), 8));
ArrayList<WeightedRandomObject> pool = new ArrayList<>();
if(soot > 2) pool.add(new WeightedRandomObject(new ItemStack(ModItems.gun_pepperbox), 10));
if(soot > 2) pool.add(new WeightedRandomObject(new ItemStack(ModItems.gun_henry), 8));
if(soot > 2) pool.add(new WeightedRandomObject(new ItemStack(ModItems.gun_greasegun), 6));
if(soot > 4) pool.add(new WeightedRandomObject(new ItemStack(ModItems.gun_maresleg), 4));
if(soot > 4) pool.add(new WeightedRandomObject(new ItemStack(ModItems.gun_uzi), 6));
if(soot > 8) pool.add(new WeightedRandomObject(new ItemStack(ModItems.gun_spas12), 3));
if(soot > 8) pool.add(new WeightedRandomObject(new ItemStack(ModItems.gun_am180), 4));
if(soot > 12) pool.add(new WeightedRandomObject(new ItemStack(ModItems.gun_congolake), 1));
if(soot < 0.3){
pool.add(new WeightedRandomObject(new ItemStack(ModItems.gun_pepperbox), 5));
pool.add(new WeightedRandomObject(null, 20));
} else if(soot > 0.3 && soot < 1) {
pool.addAll(MobUtil.slotPoolGuns.get(0.3));
} else if (soot < 3) {
pool.addAll(MobUtil.slotPoolGuns.get(1D));
} else if (soot < 5) {
pool.addAll(MobUtil.slotPoolGuns.get(3D));
} else {
pool.addAll(MobUtil.slotPoolGuns.get(5D));
}
WeightedRandomObject selected = (WeightedRandomObject) WeightedRandom.getRandomItem(rand, pool);
return selected.asStack();
}
// these fucking tasks keep stacking on top of themselves
private static void addFireTask(EntityLiving entity) {
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, new EntityAIFireGun(entity));
}
@SubscribeEvent
public void addAITasks(EntityJoinWorldEvent event) {
if(event.world.isRemote || !(event.entity instanceof EntityLiving)) return;
@ -549,7 +449,7 @@ public class ModEventHandler {
ItemStack held = living.getHeldItem();
if(held != null && held.getItem() instanceof ItemGunBaseNT) {
addFireTask(living);
MobUtil.addFireTask(living);
}
}

View File

@ -19,6 +19,7 @@ import com.hbm.blocks.generic.BlockSnowglobe.TileEntitySnowglobe;
import com.hbm.blocks.generic.BlockSupplyCrate.TileEntitySupplyCrate;
import com.hbm.blocks.generic.BlockWandJigsaw.TileEntityWandJigsaw;
import com.hbm.blocks.generic.BlockWandLoot.TileEntityWandLoot;
import com.hbm.blocks.generic.BlockWandSpawner.TileEntityWandSpawner;
import com.hbm.blocks.generic.DungeonSpawner.TileEntityDungeonSpawner;
import com.hbm.blocks.generic.PartEmitter.TileEntityPartEmitter;
import com.hbm.blocks.machine.BlockICF.TileEntityBlockICF;
@ -236,6 +237,7 @@ public class TileMappings {
put(TileEntityWandLoot.class, "tileentity_wand_loot");
put(TileEntityWandJigsaw.class, "tileentity_wand_jigsaw");
put(TileEntityWandSpawner.class, "tileentity_wand_spawner");
putNetwork();
putBombs();
@ -427,7 +429,7 @@ public class TileMappings {
put(TileEntityCranePartitioner.class, "tileentity_partitioner");
put(TileEntityFan.class, "tileentity_fan");
put(TileEntityPistonInserter.class, "tileentity_piston_inserter");
put(TileEntityPneumoTube.class, "tileentity_pneumatic_tube");
put(TileEntityRadioTorchSender.class, "tileentity_rtty_sender");

View File

@ -0,0 +1,197 @@
package com.hbm.util;
import com.hbm.entity.mob.ai.EntityAIFireGun;
import com.hbm.items.ModItems;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.EntityAITasks;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.WeightedRandom;
import java.util.*;
public class MobUtil {
public static Map<Integer, List<WeightedRandomObject>> slotPoolCommon = new HashMap<>();
public static Map<Integer, List<WeightedRandomObject>> slotPoolRanged = new HashMap<>();
public static Map<Integer, List<WeightedRandomObject>> slotPoolAdv = new HashMap<>();
public static Map<Integer, List<WeightedRandomObject>> slotPoolAdvRanged;
/**Unlike the above two, the Double is interpreted as minimum soot level, instead of armor slot **/
public static HashMap<Double, List<WeightedRandomObject>> slotPoolGuns = 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
{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[][]{
{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[][]{
{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[][]{
{ModItems.robes_boots, 32}, {ModItems.steel_boots, 16}, {ModItems.cobalt_boots, 2}, {ModItems.alloy_boots, 2}
}));
slotPoolCommon.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},
{ModItems.titanium_sword, 8}, {ModItems.lead_gavel, 4}, {ModItems.wrench_flipped, 2},
{ModItems.wrench, 20}
}));
slotPoolRanged.put(4, createSlotPool(12000, 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[][]{
{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[][]{
{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[][]{
{ModItems.robes_boots, 32}, {ModItems.steel_boots, 16}, {ModItems.cobalt_boots, 2}, {ModItems.alloy_boots, 2},
{ModItems.titanium_boots, 6}
}));
slotPoolGuns.put(0.3, createSlotPool(new Object[][]{
{ModItems.gun_light_revolver, 16}, {ModItems.gun_greasegun, 8}, {ModItems.gun_maresleg, 2}
}));
slotPoolGuns.put(1D, createSlotPool(new Object[][]{
{ModItems.gun_light_revolver, 6}, {ModItems.gun_greasegun, 8}, {ModItems.gun_maresleg, 4}, {ModItems.gun_henry, 6}
}));
slotPoolGuns.put(3D, createSlotPool(new Object[][]{
{ModItems.gun_uzi, 10}, {ModItems.gun_maresleg, 8}, {ModItems.gun_henry, 12}, {ModItems.gun_heavy_revolver, 4}, {ModItems.gun_flaregun, 2}
}));
slotPoolGuns.put(5D, createSlotPool(new Object[][]{
{ModItems.gun_am180, 6}, {ModItems.gun_uzi, 10}, {ModItems.gun_spas12, 8}, {ModItems.gun_henry_lincoln, 2}, {ModItems.gun_heavy_revolver, 12}, {ModItems.gun_flaregun, 4}, {ModItems.gun_flamer, 2}
}));
slotPoolAdv.put(4, createSlotPool(new Object[][]{
{ModItems.security_helmet, 10}, {ModItems.t45_helmet, 4}, {ModItems.asbestos_helmet, 12},
{ModItems.liquidator_helmet, 4}, {ModItems.no9, 12},
{ModItems.hazmat_helmet, 6}
}));
slotPoolAdv.put(3, createSlotPool(new Object[][]{
{ModItems.liquidator_plate, 4}, {ModItems.security_plate, 8}, {ModItems.asbestos_plate, 12},
{ModItems.t45_plate, 4}, {ModItems.hazmat_plate, 6},
{ModItems.steel_plate, 8}
}));
slotPoolAdv.put(2, createSlotPool(new Object[][]{
{ModItems.liquidator_legs, 4}, {ModItems.security_legs, 8}, {ModItems.asbestos_legs, 12},
{ModItems.t45_legs, 4}, {ModItems.hazmat_legs, 6},
{ModItems.steel_legs, 8}
}));
slotPoolAdv.put(1, createSlotPool(new Object[][]{
{ModItems.liquidator_boots, 4}, {ModItems.security_boots, 8}, {ModItems.asbestos_boots, 12},
{ModItems.t45_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},
{ModItems.sopsign, 4}, {ModItems.chernobylsign, 16},
{ModItems.titanium_sword, 18}, {ModItems.lead_gavel, 8},
{ModItems.wrench, 20}
}));
slotPoolAdvRanged = new HashMap<>(slotPoolAdv);
slotPoolAdvRanged.remove(0);
}
public static List<WeightedRandomObject> createSlotPool(int nullWeight, Object[][] items) {
List<WeightedRandomObject> pool = new ArrayList<>();
pool.add(new WeightedRandomObject(null, nullWeight));
for (Object[] item : items) {
Object obj = item[0];
int weight = (int) item[1];
if (obj instanceof Item) {
pool.add(new WeightedRandomObject(new ItemStack((Item) obj), weight));
} else if (obj instanceof ItemStack) { //lol just make it pass ItemStack aswell
pool.add(new WeightedRandomObject(obj, weight));
}
}
return pool;
}
public static List<WeightedRandomObject> createSlotPool(Object[][] items) {
List<WeightedRandomObject> pool = new ArrayList<>();
for (Object[] item : items) {
Object obj = item[0];
int weight = (int) item[1];
if (obj instanceof Item) {
pool.add(new WeightedRandomObject(new ItemStack((Item) obj), weight));
} else if (obj instanceof ItemStack) { //lol just make it pass ItemStack aswell
pool.add(new WeightedRandomObject(obj, weight));
}
}
return pool;
}
public static void equipFullSet(EntityLivingBase entity, Item helmet, Item chest, Item legs, Item boots) { //for brainlets (me) to add more armorsets later when i forget about how this works
entity.setCurrentItemOrArmor(4, new ItemStack(helmet)); //p_70062_1_ is the slot number
entity.setCurrentItemOrArmor(3, new ItemStack(chest));
entity.setCurrentItemOrArmor(2, new ItemStack(legs));
entity.setCurrentItemOrArmor(1, new ItemStack(boots));
}
public static void assignItemsToEntity(EntityLivingBase entity, Map<Integer, List<WeightedRandomObject>> slotPools, Random rand) {
for (Map.Entry<Integer, List<WeightedRandomObject>> entry : slotPools.entrySet()) {
int slot = entry.getKey();
List<WeightedRandomObject> pool = entry.getValue();
WeightedRandomObject choice = (WeightedRandomObject) WeightedRandom.getRandomItem(rand, pool); //NullPointerException sludge fix
if (choice == null) {
continue;
}
ItemStack stack = choice.asStack();
if (stack == null || stack.getItem() == null) {
continue;
}
if (stack.getItem() == ModItems.gas_mask_m65 //eyesore
|| stack.getItem() == ModItems.gas_mask_olde
|| stack.getItem() == ModItems.gas_mask_mono) {
ArmorUtil.installGasMaskFilter(stack, new ItemStack(ModItems.gas_mask_filter));
}
entity.setCurrentItemOrArmor(slot, stack);
//Give skeleton AI if it has a gun
if (slot == 0 && entity instanceof EntitySkeleton && pool == slotPools.get(0)) {
addFireTask((EntityLiving) entity);
}
}
}
// these fucking tasks keep stacking on top of themselves
public static void addFireTask(EntityLiving entity) {
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, new EntityAIFireGun(entity));
}
}

View File

@ -0,0 +1,165 @@
package com.hbm.world.gen.util;
import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.generic.BlockPedestal;
import com.hbm.blocks.generic.BlockSkeletonHolder;
import com.hbm.blocks.generic.DungeonSpawner;
import com.hbm.entity.item.EntityFallingBlockNT;
import com.hbm.entity.mob.EntityUndeadSoldier;
import com.hbm.items.ItemEnums;
import com.hbm.items.ModItems;
import com.hbm.main.ModEventHandler;
import com.hbm.tileentity.machine.storage.TileEntityCrateBase;
import com.hbm.util.MobUtil;
import com.hbm.util.Vec3NT;
import net.minecraft.entity.effect.EntityLightningBolt;
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.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Random;
import java.util.function.Consumer;
public class DungeonSpawnerActions {
public static HashMap<String, Consumer<DungeonSpawner.TileEntityDungeonSpawner>> actions = new HashMap<>();
public static Consumer<DungeonSpawner.TileEntityDungeonSpawner> PHASE_ABERRATOR = (tile) -> {
World world = tile.getWorldObj();
int x = tile.xCoord;
int y = tile.yCoord;
int z = tile.zCoord;
if (tile.phase == 1 || tile.phase == 2) {
if (tile.timer == 0) {
Vec3NT vec = new Vec3NT(10, 0, 0);
for (int i = 0; i < 10; i++) {
EntityUndeadSoldier mob = new EntityUndeadSoldier(world);
for (int j = 0; j < 7; j++) {
mob.setPositionAndRotation(x + 0.5 + vec.xCoord, y - 5, z + 0.5 + vec.zCoord, i * 36F, 0);
if (mob.getCanSpawnHere()) {
mob.onSpawnWithEgg(null);
world.spawnEntityInWorld(mob);
break;
}
}
vec.rotateAroundYDeg(36D);
}
}
}
if (tile.phase > 2) {
TileEntity te = world.getTileEntity(x, y + 18, z);
if (te instanceof BlockSkeletonHolder.TileEntitySkeletonHolder) {
BlockSkeletonHolder.TileEntitySkeletonHolder skeleton = (BlockSkeletonHolder.TileEntitySkeletonHolder) te;
if (world.rand.nextInt(5) == 0) {
skeleton.item = new ItemStack(ModItems.item_secret, 1, ItemEnums.EnumSecretType.ABERRATOR.ordinal());
} else {
skeleton.item = new ItemStack(ModItems.clay_tablet, 1, 1);
}
skeleton.markDirty();
world.markBlockForUpdate(x, y + 18, z);
}
world.setBlock(x, y, z, Blocks.obsidian);
}
};
public static Consumer<DungeonSpawner.TileEntityDungeonSpawner> COLLAPSE_ROOF_RAD_5 = (tile) -> {
World world = tile.getWorldObj();
int x = tile.xCoord;
int y = tile.yCoord;
int z = tile.zCoord;
if(tile.phase == 0) return;
//from explosionChaos because i cannot be assed
int r = 4;
int r2 = r * r;
int r22 = r2 / 2;
for (int xx = -r; xx < r; xx++) {
int X = xx + x;
int XX = xx * xx;
for (int yy = -r; yy < r; yy++) {
int Y = yy + y;
int YY = XX + yy * yy;
for (int zz = -r; zz < r; zz++) {
int Z = zz + z;
int ZZ = YY + zz * zz;
if (ZZ < r22) {
if (world.getBlock(X, Y, Z).getExplosionResistance(null) <= 70) {
EntityFallingBlockNT entityfallingblock = new EntityFallingBlockNT(world, X + 0.5, Y + 0.5, Z + 0.5, world.getBlock(X, Y, Z), world.getBlockMetadata(X, Y, Z));
world.spawnEntityInWorld(entityfallingblock);
}
}
}
}
}
world.setBlock(x, y, z, ModBlocks.block_steel);
};
public static Consumer<DungeonSpawner.TileEntityDungeonSpawner> FODDER_WAVE = (tile) -> {
World world = tile.getWorldObj();
int x = tile.xCoord;
int y = tile.yCoord;
int z = tile.zCoord;
if (tile.phase == 1) {
Vec3NT vec = new Vec3NT(5, 0, 0);
for (int i = 0; i < 10; i++) {
EntityZombie mob = new EntityZombie(world);
for (int j = 0; j < 7; j++) {
mob.setPositionAndRotation(x + 0.5 + vec.xCoord, world.getHeightValue(x,z), z + 0.5 + vec.zCoord, i * 36F, 0);
MobUtil.assignItemsToEntity(mob, MobUtil.slotPoolAdv, new Random());
if (mob.getCanSpawnHere()) {
world.spawnEntityInWorld(mob);
break;
}
}
vec.rotateAroundYDeg(36D);
}
world.setBlock(x, y, z, ModBlocks.block_steel);
}
};
public static Consumer<DungeonSpawner.TileEntityDungeonSpawner> PUZZLE_TEST = (tile) -> {
World world = tile.getWorldObj();
int x = tile.xCoord;
int y = tile.yCoord;
int z = tile.zCoord;
if(tile.phase == 2){
world.setBlock(x,y,z, ModBlocks.crate_steel);
EntityLightningBolt blitz = new EntityLightningBolt(world, x, world.getHeightValue(x, z) + 1, z);
world.spawnEntityInWorld(blitz);
TileEntityCrateBase crate = (TileEntityCrateBase) world.getTileEntity(x,y,z);
((IInventory)crate).setInventorySlotContents(15, new ItemStack(ModItems.gun_bolter));
}
};
public static List<String> getActionNames(){
return new ArrayList<>(actions.keySet());
}
//register new actions here
static{
actions.put("PHASE_ABERRATOR", PHASE_ABERRATOR);
actions.put("COLLAPSE_ROOF_RAD_5", COLLAPSE_ROOF_RAD_5);
actions.put("FODDER_WAVE", FODDER_WAVE);
actions.put("PUZZLE_TEST", PUZZLE_TEST);
}
}

View File

@ -0,0 +1,91 @@
package com.hbm.world.gen.util;
import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.generic.BlockPedestal;
import com.hbm.blocks.generic.DungeonSpawner;
import com.hbm.entity.mob.EntityUndeadSoldier;
import com.hbm.items.ModItems;
import com.hbm.tileentity.machine.storage.TileEntityCrateBase;
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 java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.function.Function;
public class DungeonSpawnerConditions {
public static HashMap<String, Function<DungeonSpawner.TileEntityDungeonSpawner, Boolean>> conditions = new HashMap<>();
public static Function<DungeonSpawner.TileEntityDungeonSpawner, Boolean> ABERRATOR = (tile) -> {
World world = tile.getWorldObj();
if(world.difficultySetting.ordinal() == 0) return false;
int x = tile.xCoord;
int y = tile.yCoord;
int z = tile.zCoord;
if(tile.phase == 0) {
if(world.getTotalWorldTime() % 20 != 0) return false;
return !world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y - 2, z + 1).expand(20, 10, 20)).isEmpty();
}
if(tile.phase < 3) {
if(world.getTotalWorldTime() % 20 != 0 || tile.timer < 60) return false;
return world.getEntitiesWithinAABB(EntityUndeadSoldier.class, AxisAlignedBB.getBoundingBox(x, y, z, x - 2, y + 1, z + 1).expand(50, 20, 50)).isEmpty();
}
return false;
};
public static Function<DungeonSpawner.TileEntityDungeonSpawner, Boolean> PLAYER_CUBE_5 = (tile) -> {
World world = tile.getWorldObj();
int x = tile.xCoord;
int y = tile.yCoord;
int z = tile.zCoord;
return !world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y - 2, z + 1).expand(5, 5, 5)).isEmpty();
};
public static Function<DungeonSpawner.TileEntityDungeonSpawner, Boolean> REDSTONE = (tile) -> {
World world = tile.getWorldObj();
int x = tile.xCoord;
int y = tile.yCoord;
int z = tile.zCoord;
return world.isBlockIndirectlyGettingPowered(x,y,z);
};
public static Function<DungeonSpawner.TileEntityDungeonSpawner, Boolean> PUZZLE_TEST = (tile) -> {
World world = tile.getWorldObj();
int x = tile.xCoord;
int y = tile.yCoord;
int z = tile.zCoord;
if(tile.phase == 0 && world.isBlockIndirectlyGettingPowered(x,y,z)){
world.getClosestPlayer(x,y,z, 25).addChatMessage(new ChatComponentText("Find a " + EnumChatFormatting.GOLD + "great" + EnumChatFormatting.RESET + " ancient weapon, of questionable use in the modern age"));
world.setBlock(x,y + 1,z, ModBlocks.pedestal);
return true;
}
TileEntity pedestal = world.getTileEntity(x,y + 1,z);
return tile.phase == 1
&& pedestal instanceof BlockPedestal.TileEntityPedestal
&& ((BlockPedestal.TileEntityPedestal) pedestal).item != null
&& ((BlockPedestal.TileEntityPedestal) pedestal).item.getItem() == ModItems.big_sword;
};
public static List<String> getConditionNames(){
return new ArrayList<>(conditions.keySet());
}
//register new conditions here
static {
conditions.put("ABERRATOR", ABERRATOR);
conditions.put("PLAYER_CUBE_5", PLAYER_CUBE_5);
conditions.put("REDSTONE", REDSTONE);
conditions.put("PUZZLE_TEST", PUZZLE_TEST);
}
}

View File

@ -6057,6 +6057,7 @@ tile.volcano_rad_core.name=Rad Volcano Core
tile.wand_air.name=Structure Wand Block (Air)
tile.wand_loot.name=Structure Wand Block (Lootable)
tile.wand_jigsaw.name=Structure Wand Block (Jigsaw)
tile.wand_spawner.name=Structure Wand Block (Actions)
tile.waste_earth.name=Dead Grass
tile.waste_leaves.name=Dead Leaves
tile.waste_log.name=Charred Log

Binary file not shown.

After

Width:  |  Height:  |  Size: 730 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 740 B