tested new power system again, new loot generator block

This commit is contained in:
Bob 2021-10-27 23:56:43 +02:00
parent 26b379e249
commit 9fe1ec57b1
8 changed files with 127 additions and 18 deletions

View File

@ -7,6 +7,7 @@ import com.hbm.blocks.ModBlocks;
import com.hbm.items.ModItems;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.bomb.TileEntityBombMulti;
import com.hbm.util.LootGenerator;
import com.hbm.util.Tuple.Quartet;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
@ -47,15 +48,7 @@ public class BlockLoot extends BlockContainer {
@Override
public void onBlockAdded(World world, int x, int y, int z) {
super.onBlockAdded(world, x, y, z);
TileEntityLoot loot = (TileEntityLoot) world.getTileEntity(x, y, z);
if(loot != null && loot.items.isEmpty()) {
for(int i = 0; i < 64; i++) {
loot.addItem(new ItemStack(ModItems.cigarette), -0.375 + world.rand.nextDouble() * 0.75, world.rand.nextDouble() * 0.0625, -0.375 + world.rand.nextDouble() * 0.75);
}
}
LootGenerator.lootMedicine(world, x, y, z);
}
@Override
@ -131,8 +124,6 @@ public class BlockLoot extends BlockContainer {
int count = nbt.getInteger("count");
System.out.println("count");
for(int i = 0; i < count; i++) {
ItemStack stack = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("item" + i));
double x = nbt.getDouble("x" + i);

View File

@ -70,12 +70,20 @@ public class HazmatRegistry {
Item rec_chest = Compat.tryLoadItem("ReactorCraft", "reactorcraft_item_hazchest");
Item rec_legs = Compat.tryLoadItem("ReactorCraft", "reactorcraft_item_hazlegs");
Item rec_boots = Compat.tryLoadItem("ReactorCraft", "reactorcraft_item_hazboots");
if(rec_helmet != null) HazmatRegistry.registerHazmat(rec_helmet, hazGray * helmet);
if(rec_chest != null) HazmatRegistry.registerHazmat(rec_chest, hazGray * chest);
if(rec_legs != null) HazmatRegistry.registerHazmat(rec_legs, hazGray * legs);
if(rec_boots != null) HazmatRegistry.registerHazmat(rec_boots, hazGray * boots);
Item efn_helmet = Compat.tryLoadItem("etfuturum", "netherite_helmet");
Item efn_chest = Compat.tryLoadItem("etfuturum", "netherite_chestplate");
Item efn_legs = Compat.tryLoadItem("etfuturum", "netherite_leggings");
Item efn_boots = Compat.tryLoadItem("etfuturum", "netherite_boots");
if(efn_helmet != null) HazmatRegistry.registerHazmat(efn_helmet, star * helmet);
if(efn_chest != null) HazmatRegistry.registerHazmat(efn_chest, star * chest);
if(efn_legs != null) HazmatRegistry.registerHazmat(efn_legs, star * legs);
if(efn_boots != null) HazmatRegistry.registerHazmat(efn_boots, star * boots);
HazmatRegistry.registerHazmat(ModItems.liquidator_helmet, liquidator * helmet);
HazmatRegistry.registerHazmat(ModItems.liquidator_plate, liquidator * chest);
HazmatRegistry.registerHazmat(ModItems.liquidator_legs, liquidator * legs);

View File

@ -32,7 +32,9 @@ public class RenderLoot extends TileEntitySpecialRenderer {
GL11.glPushMatrix();
GL11.glTranslated(item.getX(), item.getY(), item.getZ());
if(stack.getItem() == ModItems.ammo_nuke || stack.getItem() == ModItems.ammo_nuke_low || stack.getItem() == ModItems.ammo_nuke_high || stack.getItem() == ModItems.ammo_nuke_safe) {
if(stack.getItem() == ModItems.ammo_nuke || stack.getItem() == ModItems.ammo_nuke_low ||
stack.getItem() == ModItems.ammo_nuke_high || stack.getItem() == ModItems.ammo_nuke_safe ||
stack.getItem() == ModItems.ammo_nuke_pumpkin) {
renderNuke();
} else {
renderStandardItem(item.getW());

View File

@ -170,7 +170,7 @@ public class TileEntityMachineBattery extends TileEntityMachineBase implements I
short mode = (short) this.getRelevantMode();
//////////////////////////////////////////////////////////////////////
/*for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
TileEntity te = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
@ -199,12 +199,12 @@ public class TileEntityMachineBattery extends TileEntityMachineBase implements I
if(con.getPowerNet() != null && !con.getPowerNet().isSubscribed(this))
con.getPowerNet().subscribe(this);
}
}*/
}
//////////////////////////////////////////////////////////////////////
this.maxPower = ((MachineBattery)worldObj.getBlock(xCoord, yCoord, zCoord)).maxPower;
if(mode == 1 || mode == 2)
/*if(mode == 1 || mode == 2)
{
age++;
if(age >= 20)
@ -214,7 +214,7 @@ public class TileEntityMachineBattery extends TileEntityMachineBase implements I
if(age == 9 || age == 19)
ffgeuaInit();
}
}*/
power = Library.chargeTEFromItems(slots, 0, power, maxPower);
power = Library.chargeItemsFromTE(slots, 1, power, maxPower);

View File

@ -95,7 +95,7 @@ public class RBMKDials {
* @return [0;15]
*/
public static int getColumnHeight(World world) {
return MathHelper.clamp_int(shittyWorkaroundParseInt(world.getGameRules().getGameRuleStringValue(KEY_COLUMN_HEIGHT), 4), 1, 16) - 1;
return MathHelper.clamp_int(shittyWorkaroundParseInt(world.getGameRules().getGameRuleStringValue(KEY_COLUMN_HEIGHT), 4), 2, 16) - 1;
}
/**

View File

@ -0,0 +1,102 @@
package com.hbm.util;
import java.util.Random;
import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.generic.BlockLoot.TileEntityLoot;
import com.hbm.items.ModItems;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class LootGenerator {
public static void setBlock(World world, int x, int y, int z) {
world.setBlock(x, y, z, ModBlocks.deco_loot);
}
public static void addItemWithDeviation(TileEntityLoot loot, Random rand, ItemStack stack, double x, double y, double z) {
loot.addItem(stack, x + rand.nextGaussian() * 0.02, y, z + rand.nextGaussian() * 0.02);
}
public static void lootCapNuke(World world, int x, int y, int z) {
TileEntityLoot loot = (TileEntityLoot) world.getTileEntity(x, y, z);
if(loot != null && loot.items.isEmpty()) {
if(world.rand.nextInt(5) == 0)
loot.addItem(new ItemStack(ModItems.ammo_nuke_low), -0.25, 0, -0.125);
else
loot.addItem(new ItemStack(ModItems.ammo_rocket), -0.25, 0, -0.25);
for(int i = 0; i < 4; i++)
addItemWithDeviation(loot, world.rand, new ItemStack(ModItems.cap_nuka, 2), 0.125, i * 0.03125, 0.25);
for(int i = 0; i < 2; i++)
addItemWithDeviation(loot, world.rand, new ItemStack(ModItems.syringe_metal_stimpak, 1), -0.25, i * 0.03125, 0.25);
for(int i = 0; i < 6; i++)
addItemWithDeviation(loot, world.rand, new ItemStack(ModItems.cap_nuka, 2), 0.125, i * 0.03125, -0.25);
}
}
public static void lootMedicine(World world, int x, int y, int z) {
TileEntityLoot loot = (TileEntityLoot) world.getTileEntity(x, y, z);
if(loot != null && loot.items.isEmpty()) {
for(int i = 0; i < 4; i++) {
int type = world.rand.nextInt(4);
Item syringe = type < 2 ? ModItems.syringe_metal_stimpak : type == 2 ? ModItems.syringe_metal_medx : ModItems.syringe_metal_psycho;
addItemWithDeviation(loot, world.rand, new ItemStack(syringe), 0.125, i * 0.03125, 0.25);
}
int type = world.rand.nextInt(5);
Item syringe = type < 2 ? ModItems.radaway : type < 4 ? ModItems.radx : ModItems.siox;
addItemWithDeviation(loot, world.rand, new ItemStack(syringe), -0.25, 0, -0.125);
}
}
public static void lootCapStash(World world, int x, int y, int z) {
TileEntityLoot loot = (TileEntityLoot) world.getTileEntity(x, y, z);
if(loot != null && loot.items.isEmpty()) {
for(int i = -1; i <= 1; i++) {
for(int j = -1; j <= 1; j++) {
int r = world.rand.nextInt(3);
Item cap = r < 2 ? ModItems.cap_nuka : ModItems.cap_sunset;
int count = world.rand.nextInt(5) + 3;
for(int k = 0; k < count; k++) {
addItemWithDeviation(loot, world.rand, new ItemStack(cap, 4), i * 0.125, k * 0.03125, k * 0.125);
}
}
}
}
}
public static void lootNukeStorage(World world, int x, int y, int z) {
TileEntityLoot loot = (TileEntityLoot) world.getTileEntity(x, y, z);
if(loot != null && loot.items.isEmpty()) {
boolean memes = world.rand.nextInt(10) == 0;
for(int i = 0; i < 4; i++) {
for(int j = 0; j < 4; j++) {
if(world.rand.nextBoolean() || memes) {
int type = world.rand.nextInt(11);
Item nuke = memes ? ModItems.ammo_nuke_pumpkin : type == 0 ? ModItems.ammo_nuke : type <= 5 ? ModItems.ammo_nuke_low : ModItems.ammo_nuke_safe;
loot.addItem(new ItemStack(nuke), -0.375 + i * 0.25, 0, -0.375 + j * 0.25);
}
}
}
}
}
}

View File

@ -5,12 +5,14 @@ package com.hbm.world.dungeon;
import java.util.Random;
import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.generic.BlockLoot.TileEntityLoot;
import com.hbm.config.GeneralConfig;
import com.hbm.items.ModItems;
import com.hbm.lib.HbmChestContents;
import com.hbm.lib.Library;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.machine.TileEntityCrateIron;
import com.hbm.util.LootGenerator;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
@ -657,6 +659,9 @@ public class Relay extends WorldGenerator
((TileEntityCrateIron)world.getTileEntity(x + 6, y + 0, z + 10)).setInventorySlotContents(11, new ItemStack(ModItems.morning_glory));
}
LootGenerator.setBlock(world, x + 6, y + 1, z + 10);
LootGenerator.lootCapNuke(world, x + 6, y + 1, z + 10);
world.setBlock(x + 7, y + 0, z + 10, Blocks.brick_block, 0, 3);
world.setBlock(x + 8, y + 0, z + 10, Blocks.brick_block, 0, 3);
world.setBlock(x + 10, y + 0, z + 10, ModBlocks.fence_metal, 0, 3);

View File

@ -1,5 +1,6 @@
{
"animation": {
"interpolate": true,
"frametime": 4
}
}