From b7c5f89ba5207bbf24030a338ffd28268296a6ff Mon Sep 17 00:00:00 2001 From: Bob Date: Wed, 19 May 2021 23:25:33 +0200 Subject: [PATCH] HEV battery block, radiation system cleanup and preparation, sssand --- src/main/java/com/hbm/blocks/ModBlocks.java | 5 + .../com/hbm/blocks/generic/HEVBattery.java | 87 ++++++ .../hbm/handler/BulletConfigSyncingUtil.java | 2 +- .../hbm/handler/RadiationWorldHandler.java | 1 + .../hbm/handler/guncfg/GunEnergyFactory.java | 74 +++-- .../ChunkRadiationHandlerSimple.java | 128 +++++++- .../radiation/ChunkRadiationManager.java | 16 +- .../java/com/hbm/items/weapon/ItemAmmo.java | 6 + src/main/java/com/hbm/main/ClientProxy.java | 1 + src/main/java/com/hbm/main/MainRegistry.java | 14 +- .../java/com/hbm/main/ResourceManager.java | 1 + .../com/hbm/render/block/RenderBattery.java | 69 +++++ .../com/hbm/render/block/RenderPribris.java | 44 ++- .../com/hbm/saveddata/RadiationSavedData.java | 28 +- .../assets/hbm/models/blocks/battery.obj | 284 ++++++++++++++++++ .../hbm/textures/blocks/hev_battery.png | Bin 0 -> 382 bytes 16 files changed, 697 insertions(+), 63 deletions(-) create mode 100644 src/main/java/com/hbm/blocks/generic/HEVBattery.java create mode 100644 src/main/java/com/hbm/render/block/RenderBattery.java create mode 100644 src/main/resources/assets/hbm/models/blocks/battery.obj create mode 100644 src/main/resources/assets/hbm/textures/blocks/hev_battery.png diff --git a/src/main/java/com/hbm/blocks/ModBlocks.java b/src/main/java/com/hbm/blocks/ModBlocks.java index 96cc6d8f3..00186ea93 100644 --- a/src/main/java/com/hbm/blocks/ModBlocks.java +++ b/src/main/java/com/hbm/blocks/ModBlocks.java @@ -323,6 +323,7 @@ public class ModBlocks { public static Block broadcaster_pc; public static Block geiger; + public static Block hev_battery; public static Block fence_metal; @@ -1329,6 +1330,7 @@ public class ModBlocks { broadcaster_pc = new PinkCloudBroadcaster(Material.iron).setBlockName("broadcaster_pc").setCreativeTab(MainRegistry.machineTab).setHardness(5.0F).setResistance(15.0F).setBlockTextureName(RefStrings.MODID + ":broadcaster_pc"); geiger = new GeigerCounter(Material.iron).setBlockName("geiger").setCreativeTab(MainRegistry.machineTab).setHardness(15.0F).setResistance(0.25F).setBlockTextureName(RefStrings.MODID + ":geiger"); + hev_battery = new HEVBattery(Material.iron).setBlockName("hev_battery").setCreativeTab(MainRegistry.machineTab).setLightLevel(5F/15F).setHardness(0.5F).setResistance(0.25F).setBlockTextureName(RefStrings.MODID + ":hev_battery"); fence_metal = new BlockMetalFence(Material.iron).setBlockName("fence_metal").setCreativeTab(MainRegistry.machineTab).setHardness(15.0F).setResistance(0.25F).setBlockTextureName(RefStrings.MODID + ":fence_metal"); @@ -2293,6 +2295,9 @@ public class ModBlocks { //Geiger Counter GameRegistry.registerBlock(geiger, geiger.getUnlocalizedName()); + //HEV Battery + GameRegistry.registerBlock(hev_battery, hev_battery.getUnlocalizedName()); + //Chainlink Fence GameRegistry.registerBlock(fence_metal, fence_metal.getUnlocalizedName()); diff --git a/src/main/java/com/hbm/blocks/generic/HEVBattery.java b/src/main/java/com/hbm/blocks/generic/HEVBattery.java new file mode 100644 index 000000000..dbaa4f89d --- /dev/null +++ b/src/main/java/com/hbm/blocks/generic/HEVBattery.java @@ -0,0 +1,87 @@ +package com.hbm.blocks.generic; + +import com.hbm.items.armor.ArmorFSB; +import com.hbm.items.armor.ArmorFSBPowered; + +import api.hbm.energy.IBatteryItem; +import cpw.mods.fml.client.registry.RenderingRegistry; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class HEVBattery extends Block { + + public HEVBattery(Material mat) { + super(mat); + } + + public static int renderID = RenderingRegistry.getNextAvailableRenderId(); + + @Override + public int getRenderType() { + return renderID; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { + float f = 0.0625F; + this.setBlockBounds(6 * f, 0.0F, 6 * f, 10 * f, 6 * f, 10 * f); + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { + float f = 0.0625F; + this.setBlockBounds(6 * f, 0.0F, 6 * f, 10 * f, 6 * f, 10 * f); + return AxisAlignedBB.getBoundingBox(x + this.minX, y + this.minY, z + this.minZ, x + this.maxX, y + this.maxY, z + this.maxZ); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { + + if(world.isRemote) { + return true; + + } else if(!player.isSneaking()) { + + if(ArmorFSB.hasFSBArmorIgnoreCharge(player) && player.inventory.armorInventory[3].getItem() instanceof ArmorFSBPowered) { + + for(ItemStack st : player.inventory.armorInventory) { + + if(st == null) + continue; + + if(st.getItem() instanceof IBatteryItem) { + + long maxcharge = ((IBatteryItem) st.getItem()).getMaxCharge(); + long charge = ((IBatteryItem) st.getItem()).getCharge(st); + long newcharge = Math.min(charge + 150000, maxcharge); + + ((IBatteryItem) st.getItem()).setCharge(st, newcharge); + } + } + + world.playSoundAtEntity(player, "hbm:item.battery", 1.0F, 1.0F); + world.setBlock(x, y, z, Blocks.air, 0, 3); + } + + return true; + } else { + return false; + } + } +} diff --git a/src/main/java/com/hbm/handler/BulletConfigSyncingUtil.java b/src/main/java/com/hbm/handler/BulletConfigSyncingUtil.java index 6d2886010..360521f5c 100644 --- a/src/main/java/com/hbm/handler/BulletConfigSyncingUtil.java +++ b/src/main/java/com/hbm/handler/BulletConfigSyncingUtil.java @@ -365,7 +365,7 @@ public class BulletConfigSyncingUtil { configSet.put(FEXT_NORMAL, GunEnergyFactory.getFextConfig()); configSet.put(FEXT_FOAM, GunEnergyFactory.getFextFoamConfig()); - configSet.put(FEXT_SAND, GunEnergyFactory.getFlameConfig()); + configSet.put(FEXT_SAND, GunEnergyFactory.getFextSandConfig()); configSet.put(R556_NORMAL, Gun556mmFactory.get556Config()); configSet.put(R556_GOLD, Gun556mmFactory.get556GoldConfig()); diff --git a/src/main/java/com/hbm/handler/RadiationWorldHandler.java b/src/main/java/com/hbm/handler/RadiationWorldHandler.java index dca7a0e54..9caea1b3b 100644 --- a/src/main/java/com/hbm/handler/RadiationWorldHandler.java +++ b/src/main/java/com/hbm/handler/RadiationWorldHandler.java @@ -4,6 +4,7 @@ import java.util.Map.Entry; import com.hbm.blocks.ModBlocks; import com.hbm.config.RadiationConfig; +import com.hbm.handler.radiation.ChunkRadiationManager; import com.hbm.saveddata.RadiationSavedData; import net.minecraft.entity.player.EntityPlayer; diff --git a/src/main/java/com/hbm/handler/guncfg/GunEnergyFactory.java b/src/main/java/com/hbm/handler/guncfg/GunEnergyFactory.java index 7c227c15e..e77b2518e 100644 --- a/src/main/java/com/hbm/handler/guncfg/GunEnergyFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/GunEnergyFactory.java @@ -387,25 +387,10 @@ public class GunEnergyFactory { public static BulletConfiguration getFextFoamConfig() { - BulletConfiguration bullet = new BulletConfiguration(); + BulletConfiguration bullet = getFextConfig(); bullet.ammo = ModItems.ammo_fireext_foam; - bullet.ammoCount = 300; - - bullet.velocity = 0.75F; - bullet.spread = 0.025F; - bullet.wear = 1; - bullet.bulletsMin = 2; - bullet.bulletsMax = 3; - bullet.dmgMin = 0; - bullet.dmgMax = 0; - bullet.gravity = 0.04D; - bullet.maxAge = 100; - bullet.doesRicochet = false; - bullet.doesPenetrate = true; - bullet.doesBreakGlass = false; - bullet.style = BulletConfiguration.STYLE_NONE; - bullet.plink = BulletConfiguration.PLINK_NONE; + bullet.spread = 0.05F; bullet.bImpact = new IBulletImpactBehavior() { @@ -471,6 +456,61 @@ public class GunEnergyFactory { return bullet; } + public static BulletConfiguration getFextSandConfig() { + + BulletConfiguration bullet = getFextConfig(); + + bullet.ammo = ModItems.ammo_fireext_sand; + bullet.spread = 0.1F; + + bullet.bImpact = new IBulletImpactBehavior() { + + @Override + public void behaveBlockHit(EntityBulletBase bullet, int x, int y, int z) { + + if(!bullet.worldObj.isRemote) { + + int ix = (int)Math.floor(bullet.posX); + int iy = (int)Math.floor(bullet.posY); + int iz = (int)Math.floor(bullet.posZ); + + Block b = bullet.worldObj.getBlock(ix, iy, iz); + + if(b != ModBlocks.sand_boron_layer && b.isReplaceable(bullet.worldObj, ix, iy, iz) && ModBlocks.sand_boron_layer.canPlaceBlockAt(bullet.worldObj, ix, iy, iz)) { + bullet.worldObj.setBlock(ix, iy, iz, ModBlocks.sand_boron_layer); + + if(b.getMaterial() == Material.fire) + bullet.worldObj.playSoundEffect(bullet.posX, bullet.posY, bullet.posZ, "random.fizz", 1.0F, 1.5F + bullet.worldObj.rand.nextFloat() * 0.5F); + } + } + } + }; + + bullet.bUpdate = new IBulletUpdateBehavior() { + + @Override + public void behaveUpdate(EntityBulletBase bullet) { + + if(bullet.worldObj.isRemote) { + + NBTTagCompound data = new NBTTagCompound(); + data.setString("type", "vanillaExt"); + data.setString("mode", "blockdust"); + data.setInteger("block", Block.getIdFromBlock(ModBlocks.sand_boron)); + data.setDouble("posX", bullet.posX); + data.setDouble("posY", bullet.posY); + data.setDouble("posZ", bullet.posZ); + data.setDouble("mX", bullet.motionX + bullet.worldObj.rand.nextGaussian() * 0.1); + data.setDouble("mY", bullet.motionY - 0.2 + bullet.worldObj.rand.nextGaussian() * 0.1); + data.setDouble("mZ", bullet.motionZ + bullet.worldObj.rand.nextGaussian() * 0.1); + MainRegistry.proxy.effectNT(data); + } + } + }; + + return bullet; + } + public static BulletConfiguration getZOMGBoltConfig() { BulletConfiguration bullet = new BulletConfiguration(); diff --git a/src/main/java/com/hbm/handler/radiation/ChunkRadiationHandlerSimple.java b/src/main/java/com/hbm/handler/radiation/ChunkRadiationHandlerSimple.java index 10d0e9619..35f46becb 100644 --- a/src/main/java/com/hbm/handler/radiation/ChunkRadiationHandlerSimple.java +++ b/src/main/java/com/hbm/handler/radiation/ChunkRadiationHandlerSimple.java @@ -1,36 +1,150 @@ package com.hbm.handler.radiation; +import java.util.HashMap; +import java.util.Map.Entry; + +import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.World; +import net.minecraftforge.event.world.ChunkDataEvent; +import net.minecraftforge.event.world.ChunkEvent; +import net.minecraftforge.event.world.WorldEvent; public class ChunkRadiationHandlerSimple extends ChunkRadiationHandler { + + private HashMap perWorld = new HashMap(); @Override public float getRadiation(World world, int x, int y, int z) { - // TODO Auto-generated method stub + SimpleRadiationPerWorld radWorld = perWorld.get(world); + + if(radWorld != null) { + ChunkCoordIntPair coords = new ChunkCoordIntPair(x >> 4, z >> 4); + Float rad = radWorld.radiation.get(coords); + return rad == null ? 0F : rad; + } + return 0; } @Override public void setRadiation(World world, int x, int y, int z, float rad) { - // TODO Auto-generated method stub + SimpleRadiationPerWorld radWorld = perWorld.get(world); + if(radWorld != null) { + + if(world.blockExists(x, 0, z)) { + + ChunkCoordIntPair coords = new ChunkCoordIntPair(x >> 4, z >> 4); + + if(radWorld.radiation.containsKey(coords)) { + radWorld.radiation.put(coords, rad); + } + + world.getChunkFromBlockCoords(x, z).isModified = true; + } + } } @Override public void incrementRad(World world, int x, int y, int z, float rad) { - // TODO Auto-generated method stub - + setRadiation(world, x, y, z, getRadiation(world, x, y, z) + rad); } @Override public void decrementRad(World world, int x, int y, int z, float rad) { - // TODO Auto-generated method stub - + setRadiation(world, x, y, z, Math.max(getRadiation(world, x, y, z) - rad, 0)); } @Override public void updateSystem() { - // TODO Auto-generated method stub + for(Entry entry : perWorld.entrySet()) { + + HashMap radiation = entry.getValue().radiation; + HashMap buff = new HashMap(radiation); + radiation.clear(); + + for(Entry chunk : buff.entrySet()) { + + ChunkCoordIntPair coord = chunk.getKey(); + + for(int i = -1; i <= 1; i++) { + for(int j = -1; j<= 1; j++) { + + int type = Math.abs(i) + Math.abs(j); + float percent = type == 0 ? 0.6F : type == 1 ? 0.075F : 0.025F; + ChunkCoordIntPair newCoord = new ChunkCoordIntPair(coord.chunkXPos + i, coord.chunkZPos + j); + + if(buff.containsKey(newCoord)) { + Float val = radiation.get(newCoord); + float rad = val == null ? 0 : val; + float newRad = rad + chunk.getValue() * percent; + newRad = Math.max(0F, newRad * 0.999F - 0.05F); + radiation.put(newCoord, newRad); + } + } + } + } + } + } + + @Override + public void receiveWorldLoad(WorldEvent.Load event) { + if(!event.world.isRemote) + perWorld.put(event.world, new SimpleRadiationPerWorld()); + } + + @Override + public void receiveWorldUnload(WorldEvent.Unload event) { + if(!event.world.isRemote) + perWorld.remove(event.world); + } + + private static final String NBT_KEY_CHUNK_RADIATION = "hfr_simple_radiation"; + + @Override + public void receiveChunkLoad(ChunkDataEvent.Load event) { + + if(!event.world.isRemote) { + SimpleRadiationPerWorld radWorld = perWorld.get(event.world); + + if(radWorld != null) { + radWorld.radiation.put(event.getChunk().getChunkCoordIntPair(), event.getData().getFloat(NBT_KEY_CHUNK_RADIATION)); + } + } + } + + @Override + public void receiveChunkSave(ChunkDataEvent.Save event) { + + if(!event.world.isRemote) { + SimpleRadiationPerWorld radWorld = perWorld.get(event.world); + + if(radWorld != null) { + Float val = radWorld.radiation.get(event.getChunk().getChunkCoordIntPair()); + float rad = val == null ? 0F : val; + event.getData().setFloat(NBT_KEY_CHUNK_RADIATION, rad); + + if(rad > 0) { + } + } + } + } + + @Override + public void receiveChunkUnload(ChunkEvent.Unload event) { + + if(!event.world.isRemote) { + SimpleRadiationPerWorld radWorld = perWorld.get(event.world); + + if(radWorld != null) { + radWorld.radiation.remove(event.getChunk()); + } + } + } + + public static class SimpleRadiationPerWorld { + + public HashMap radiation = new HashMap(); } } diff --git a/src/main/java/com/hbm/handler/radiation/ChunkRadiationManager.java b/src/main/java/com/hbm/handler/radiation/ChunkRadiationManager.java index 535d6e1ef..8c0e38ad0 100644 --- a/src/main/java/com/hbm/handler/radiation/ChunkRadiationManager.java +++ b/src/main/java/com/hbm/handler/radiation/ChunkRadiationManager.java @@ -2,14 +2,15 @@ package com.hbm.handler.radiation; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent; -import net.minecraft.world.World; +import cpw.mods.fml.common.gameevent.TickEvent.Phase; +import cpw.mods.fml.relauncher.Side; import net.minecraftforge.event.world.ChunkDataEvent; import net.minecraftforge.event.world.ChunkEvent; import net.minecraftforge.event.world.WorldEvent; public class ChunkRadiationManager { - public static ChunkRadiationHandler proxy; + public static ChunkRadiationHandler proxy = new ChunkRadiationHandlerSimple(); @SubscribeEvent public void onWorldLoad(WorldEvent.Load event) { @@ -36,8 +37,19 @@ public class ChunkRadiationManager { proxy.receiveChunkUnload(event); } + int eggTimer = 0; + @SubscribeEvent public void updateSystem(TickEvent.ServerTickEvent event) { + if(event.side == Side.SERVER && event.phase == Phase.END) { + + eggTimer++; + + if(eggTimer >= 20) { + proxy.updateSystem(); + eggTimer = 0; + } + } } } diff --git a/src/main/java/com/hbm/items/weapon/ItemAmmo.java b/src/main/java/com/hbm/items/weapon/ItemAmmo.java index 485bdf879..db953b150 100644 --- a/src/main/java/com/hbm/items/weapon/ItemAmmo.java +++ b/src/main/java/com/hbm/items/weapon/ItemAmmo.java @@ -444,6 +444,12 @@ public class ItemAmmo extends Item { if(this == ModItems.ammo_fireext_foam) { list.add(EnumChatFormatting.BLUE + "+ Can put out any fire type"); list.add(EnumChatFormatting.BLUE + "+ Creates protective foam layer"); + list.add(EnumChatFormatting.YELLOW + "* Broader spray"); + } + if(this == ModItems.ammo_fireext_sand) { + list.add(EnumChatFormatting.BLUE + "+ Creates protective sand layer"); + list.add(EnumChatFormatting.YELLOW + "* Very broad spray"); + list.add(EnumChatFormatting.RED + "- No extinguishing AoE"); } //5.56mm diff --git a/src/main/java/com/hbm/main/ClientProxy.java b/src/main/java/com/hbm/main/ClientProxy.java index 43e84fd4f..6edc3cd29 100644 --- a/src/main/java/com/hbm/main/ClientProxy.java +++ b/src/main/java/com/hbm/main/ClientProxy.java @@ -542,6 +542,7 @@ public class ClientProxy extends ServerProxy { RenderingRegistry.registerBlockHandler(new RenderMirror()); RenderingRegistry.registerBlockHandler(new RenderGrate()); RenderingRegistry.registerBlockHandler(new RenderPipe()); + RenderingRegistry.registerBlockHandler(new RenderBattery()); RenderingRegistry.registerBlockHandler(new RenderRBMKRod()); RenderingRegistry.registerBlockHandler(new RenderRBMKReflector()); diff --git a/src/main/java/com/hbm/main/MainRegistry.java b/src/main/java/com/hbm/main/MainRegistry.java index 10c4dfb0c..b492daeb5 100644 --- a/src/main/java/com/hbm/main/MainRegistry.java +++ b/src/main/java/com/hbm/main/MainRegistry.java @@ -1132,13 +1132,17 @@ public class MainRegistry { if(logger == null) logger = event.getModLog(); - FMLCommonHandler.instance().bus().register(new ModEventHandler()); - MinecraftForge.EVENT_BUS.register(new ModEventHandler()); - MinecraftForge.TERRAIN_GEN_BUS.register(new ModEventHandler()); - MinecraftForge.ORE_GEN_BUS.register(new ModEventHandler()); + ModEventHandler commonHandler = new ModEventHandler(); + FMLCommonHandler.instance().bus().register(commonHandler); + MinecraftForge.EVENT_BUS.register(commonHandler); + MinecraftForge.TERRAIN_GEN_BUS.register(commonHandler); + MinecraftForge.ORE_GEN_BUS.register(commonHandler); + PacketDispatcher.registerPackets(); - MinecraftForge.EVENT_BUS.register(new ChunkRadiationManager()); + ChunkRadiationManager radiationSystem = new ChunkRadiationManager(); + MinecraftForge.EVENT_BUS.register(radiationSystem); + FMLCommonHandler.instance().bus().register(radiationSystem); } //yes kids, this is where we would usually register commands diff --git a/src/main/java/com/hbm/main/ResourceManager.java b/src/main/java/com/hbm/main/ResourceManager.java index 069fdc8a0..1ad24d043 100644 --- a/src/main/java/com/hbm/main/ResourceManager.java +++ b/src/main/java/com/hbm/main/ResourceManager.java @@ -1017,6 +1017,7 @@ public class ResourceManager { public static final IModelCustom rbmk_console = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/rbmk/rbmk_console.obj")); public static final IModelCustom rbmk_debris = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/rbmk/debris.obj")); public static final ResourceLocation rbmk_console_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/rbmk_control.png"); + public static final IModelCustom hev_battery = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/blocks/battery.obj")); //RBMK DEBRIS public static final IModelCustom deb_blank = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/projectiles/deb_blank.obj")); diff --git a/src/main/java/com/hbm/render/block/RenderBattery.java b/src/main/java/com/hbm/render/block/RenderBattery.java new file mode 100644 index 000000000..cb5360c66 --- /dev/null +++ b/src/main/java/com/hbm/render/block/RenderBattery.java @@ -0,0 +1,69 @@ +package com.hbm.render.block; + +import org.lwjgl.opengl.GL11; + +import com.hbm.blocks.generic.HEVBattery; +import com.hbm.main.ResourceManager; +import com.hbm.render.util.ObjUtil; + +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.client.model.obj.WavefrontObject; + +public class RenderBattery implements ISimpleBlockRenderingHandler { + + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + + GL11.glPushMatrix(); + Tessellator tessellator = Tessellator.instance; + IIcon iicon = block.getIcon(0, 0); + tessellator.setColorOpaque_F(1, 1, 1); + + if(renderer.hasOverrideBlockTexture()) { + iicon = renderer.overrideBlockTexture; + } + + GL11.glTranslated(0, -0.625, 0); + GL11.glScaled(3.0D, 3.0D, 3.0D); + tessellator.startDrawingQuads(); + ObjUtil.renderWithIcon((WavefrontObject) ResourceManager.hev_battery, iicon, tessellator, 0, false); + tessellator.draw(); + + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + + Tessellator tessellator = Tessellator.instance; + IIcon iicon = block.getIcon(0, world.getBlockMetadata(x, y, z)); + + tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z)); + tessellator.setColorOpaque_F(1, 1, 1); + + if(renderer.hasOverrideBlockTexture()) { + iicon = renderer.overrideBlockTexture; + } + + tessellator.addTranslation(x + 0.5F, y, z + 0.5F); + ObjUtil.renderWithIcon((WavefrontObject) ResourceManager.hev_battery, iicon, tessellator, 0, true); + tessellator.addTranslation(-x - 0.5F, -y, -z - 0.5F); + + return true; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return HEVBattery.renderID; + } +} diff --git a/src/main/java/com/hbm/render/block/RenderPribris.java b/src/main/java/com/hbm/render/block/RenderPribris.java index 69d154253..27a5cdc63 100644 --- a/src/main/java/com/hbm/render/block/RenderPribris.java +++ b/src/main/java/com/hbm/render/block/RenderPribris.java @@ -20,41 +20,39 @@ public class RenderPribris implements ISimpleBlockRenderingHandler { public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { GL11.glPushMatrix(); - Tessellator tessellator = Tessellator.instance; - IIcon iicon = block.getIcon(0, 0); + Tessellator tessellator = Tessellator.instance; + IIcon iicon = block.getIcon(0, 0); tessellator.setColorOpaque_F(1, 1, 1); - if (renderer.hasOverrideBlockTexture()) - { - iicon = renderer.overrideBlockTexture; - } + if(renderer.hasOverrideBlockTexture()) { + iicon = renderer.overrideBlockTexture; + } - GL11.glTranslated(0, -0.5, 0); - tessellator.startDrawingQuads(); + GL11.glTranslated(0, -0.5, 0); + tessellator.startDrawingQuads(); ObjUtil.renderWithIcon((WavefrontObject) ResourceManager.rbmk_debris, iicon, tessellator, 0, false); tessellator.draw(); - - GL11.glPopMatrix(); + + GL11.glPopMatrix(); } @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - - Tessellator tessellator = Tessellator.instance; - IIcon iicon = block.getIcon(0, world.getBlockMetadata(x, y, z)); - - tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z)); + + Tessellator tessellator = Tessellator.instance; + IIcon iicon = block.getIcon(0, world.getBlockMetadata(x, y, z)); + + tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z)); tessellator.setColorOpaque_F(1, 1, 1); - if (renderer.hasOverrideBlockTexture()) - { - iicon = renderer.overrideBlockTexture; - } - - tessellator.addTranslation(x + 0.5F, y, z + 0.5F); + if(renderer.hasOverrideBlockTexture()) { + iicon = renderer.overrideBlockTexture; + } + + tessellator.addTranslation(x + 0.5F, y, z + 0.5F); ObjUtil.renderWithIcon((WavefrontObject) ResourceManager.rbmk_debris, iicon, tessellator, 0, true); - tessellator.addTranslation(-x - 0.5F, -y, -z - 0.5F); - + tessellator.addTranslation(-x - 0.5F, -y, -z - 0.5F); + return true; } diff --git a/src/main/java/com/hbm/saveddata/RadiationSavedData.java b/src/main/java/com/hbm/saveddata/RadiationSavedData.java index b46ab859d..f1f571e1f 100644 --- a/src/main/java/com/hbm/saveddata/RadiationSavedData.java +++ b/src/main/java/com/hbm/saveddata/RadiationSavedData.java @@ -5,6 +5,7 @@ import java.util.Map.Entry; import com.hbm.config.GeneralConfig; import com.hbm.config.RadiationConfig; +import com.hbm.handler.radiation.ChunkRadiationManager; import com.hbm.main.MainRegistry; import com.hbm.packet.AuxParticlePacket; import com.hbm.packet.PacketDispatcher; @@ -16,6 +17,7 @@ import net.minecraft.world.World; import net.minecraft.world.WorldSavedData; import net.minecraft.world.chunk.Chunk; +//TODO: urgent, change all references to this abomination to the new system and then put it to death public class RadiationSavedData extends WorldSavedData { public HashMap contamination = new HashMap(); @@ -44,22 +46,28 @@ public class RadiationSavedData extends WorldSavedData { public void setRadForCoord(int x, int y, float radiation) { - ChunkCoordIntPair pair = new ChunkCoordIntPair(x, y); + ChunkRadiationManager.proxy.setRadiation(this.worldObj, x, 0, y, radiation); + /*ChunkCoordIntPair pair = new ChunkCoordIntPair(x, y); contamination.put(pair, radiation); - this.markDirty(); + this.markDirty();*/ } public float getRadNumFromCoord(int x, int y) { - ChunkCoordIntPair pair = new ChunkCoordIntPair(x, y); + return ChunkRadiationManager.proxy.getRadiation(this.worldObj, (x << 4) + 8, 0, (y << 4) + 8); + + /*ChunkCoordIntPair pair = new ChunkCoordIntPair(x, y); Float rad = contamination.get(pair); - return rad == null ? 0 : rad; + return rad == null ? 0 : rad;*/ } public void updateSystem() { + if(true) + return; + HashMap tempList = new HashMap(contamination); contamination.clear(); @@ -183,7 +191,9 @@ public class RadiationSavedData extends WorldSavedData { public static void incrementRad(World worldObj, int x, int z, float rad, float maxRad) { - RadiationSavedData data = getData(worldObj); + ChunkRadiationManager.proxy.incrementRad(worldObj, x, 0, z, rad); + + /*RadiationSavedData data = getData(worldObj); Chunk chunk = worldObj.getChunkFromBlockCoords(x, z); @@ -192,12 +202,14 @@ public class RadiationSavedData extends WorldSavedData { if(r < maxRad) { data.setRadForCoord(chunk.xPosition, chunk.zPosition, r + rad); - } + }*/ } public static void decrementRad(World worldObj, int x, int z, float rad) { - RadiationSavedData data = getData(worldObj); + ChunkRadiationManager.proxy.decrementRad(worldObj, x, 0, z, rad); + + /*RadiationSavedData data = getData(worldObj); Chunk chunk = worldObj.getChunkFromBlockCoords(x, z); @@ -209,7 +221,7 @@ public class RadiationSavedData extends WorldSavedData { data.setRadForCoord(chunk.xPosition, chunk.zPosition, r); } else { data.setRadForCoord(chunk.xPosition, chunk.zPosition, 0); - } + }*/ } } diff --git a/src/main/resources/assets/hbm/models/blocks/battery.obj b/src/main/resources/assets/hbm/models/blocks/battery.obj new file mode 100644 index 000000000..ef824984f --- /dev/null +++ b/src/main/resources/assets/hbm/models/blocks/battery.obj @@ -0,0 +1,284 @@ +# Blender v2.79 (sub 0) OBJ File: 'battery.blend' +# www.blender.org +o Plane +v -0.125000 0.031250 0.093750 +v 0.125000 0.031250 0.093750 +v -0.125000 0.031250 -0.093750 +v 0.125000 0.031250 -0.093750 +v -0.093750 0.000000 0.093750 +v 0.093750 0.000000 0.093750 +v -0.093750 0.000000 -0.093750 +v 0.093750 0.000000 -0.093750 +v 0.093750 0.031250 0.125000 +v 0.093750 0.031250 -0.125000 +v -0.093750 0.031250 0.125000 +v -0.093750 0.031250 -0.125000 +v -0.125000 0.343750 0.093750 +v 0.125000 0.343750 0.093750 +v -0.125000 0.343750 -0.093750 +v 0.125000 0.343750 -0.093750 +v 0.093750 0.343750 0.125000 +v 0.093750 0.343750 -0.125000 +v -0.093750 0.343750 0.125000 +v -0.093750 0.343750 -0.125000 +v -0.093750 0.375000 0.093750 +v 0.093750 0.375000 0.093750 +v -0.093750 0.375000 -0.093750 +v 0.093750 0.375000 -0.093750 +v 0.000000 0.343750 0.015625 +v -0.033146 0.343750 0.029354 +v -0.046875 0.343750 0.062500 +v -0.033146 0.343750 0.095646 +v 0.000000 0.343750 0.109375 +v 0.033146 0.343750 0.095646 +v 0.046875 0.343750 0.062500 +v 0.033146 0.343750 0.029354 +v 0.000000 0.406250 0.015625 +v -0.033146 0.406250 0.029354 +v -0.046875 0.406250 0.062500 +v -0.033146 0.406250 0.095646 +v 0.000000 0.406250 0.109375 +v 0.033146 0.406250 0.095646 +v 0.046875 0.406250 0.062500 +v 0.033146 0.406250 0.029354 +v -0.046875 0.390625 -0.093750 +v 0.046875 0.390625 -0.093750 +v 0.046875 0.375000 -0.093750 +v -0.046875 0.375000 -0.031250 +v 0.046875 0.375000 -0.031250 +v 0.046875 0.390625 -0.031250 +v -0.046875 0.390625 -0.031250 +v -0.046875 0.375000 -0.093750 +v -0.031250 0.368528 -0.062500 +v -0.031250 0.390625 -0.084597 +v 0.031250 0.390625 -0.084597 +v 0.031250 0.368528 -0.062500 +v -0.031250 0.434819 0.003791 +v -0.031250 0.456916 -0.018306 +v 0.031250 0.456916 -0.018306 +v 0.031250 0.434819 0.003791 +v 0.000000 0.406250 0.062500 +vt -0.000000 0.062500 +vt 0.062500 0.000000 +vt 0.062500 0.062500 +vt 0.437500 -0.000000 +vt 0.812500 0.375000 +vt 0.437500 0.375000 +vt 0.437500 0.062500 +vt 0.062500 0.062500 +vt -0.000000 0.062500 +vt 0.062500 0.000000 +vt 0.437500 0.000000 +vt 0.437500 0.062500 +vt 0.062500 -0.000000 +vt 0.062500 0.062500 +vt 0.000000 0.062500 +vt 0.437500 0.062500 +vt 0.062500 0.062500 +vt -0.000000 0.062500 +vt 0.062500 -0.000000 +vt 0.437500 -0.000000 +vt 0.437500 0.062500 +vt 0.000000 0.687500 +vt 0.062500 0.687500 +vt 0.062500 0.687500 +vt 0.437500 0.687500 +vt 0.437500 0.687500 +vt 0.062500 0.687500 +vt 0.437500 0.687500 +vt 0.437500 0.687500 +vt 0.812500 0.375000 +vt 0.437500 0.750000 +vt 0.437500 0.375000 +vt 0.437500 0.750000 +vt 0.437500 0.750000 +vt 0.062500 0.687500 +vt 0.437500 0.750000 +vt 0.000000 0.687500 +vt 0.062500 0.750000 +vt 0.062500 0.750000 +vt -0.000000 0.687500 +vt 0.062500 0.750000 +vt 0.062500 0.750000 +vt -0.000000 0.687500 +vt 0.937500 0.000000 +vt 0.875000 0.125000 +vt 0.875000 0.000000 +vt 0.937500 -0.000000 +vt 0.875000 0.125000 +vt 0.875000 -0.000000 +vt 0.937500 0.000000 +vt 0.875000 0.125000 +vt 0.875000 0.000000 +vt 0.937500 -0.000000 +vt 0.875000 0.125000 +vt 0.875000 -0.000000 +vt 0.812500 0.125000 +vt 0.812500 -0.000000 +vt 0.812500 0.125000 +vt 0.812500 -0.000000 +vt 0.812500 0.125000 +vt 0.812500 -0.000000 +vt 0.812500 0.125000 +vt 0.812500 0.000000 +vt 0.812500 0.250000 +vt 0.187500 0.750000 +vt -0.000000 0.812500 +vt -0.000000 0.750000 +vt 0.187500 0.812500 +vt -0.000000 0.750000 +vt 0.187500 0.750000 +vt 0.187500 0.812500 +vt -0.000000 0.937500 +vt 0.250000 0.812500 +vt 0.187500 0.937500 +vt 0.187500 0.937500 +vt 0.250000 0.812500 +vt 0.250000 0.937500 +vt 0.250000 0.875000 +vt 0.625000 0.750000 +vt 0.625000 0.875000 +vt 0.687500 0.875000 +vt 0.687500 0.750000 +vt 0.250000 0.875000 +vt 0.625000 0.750000 +vt 0.625000 0.875000 +vt 0.687500 0.750000 +vt 0.687500 0.875000 +vt 0.625000 1.000000 +vt 0.875000 0.250000 +vt 0.937500 0.125000 +vt 0.937500 0.125000 +vt 0.937500 0.125000 +vt 0.937500 0.125000 +vt 0.812500 -0.000000 +vt 0.437500 -0.000000 +vt 0.812500 0.750000 +vt -0.000000 0.812500 +vt 0.250000 0.937500 +vt 0.250000 0.750000 +vt 0.250000 0.750000 +vt 0.250000 1.000000 +vn 0.5774 -0.5774 -0.5774 +vn 0.0000 -1.0000 0.0000 +vn 0.0000 -0.7071 -0.7071 +vn -0.5774 -0.5774 -0.5774 +vn -0.7071 -0.7071 0.0000 +vn -0.5774 -0.5774 0.5774 +vn 0.0000 -0.7071 0.7071 +vn 0.5774 -0.5774 0.5774 +vn 0.7071 -0.7071 0.0000 +vn 0.7071 0.0000 -0.7071 +vn 0.7071 0.0000 0.7071 +vn -0.7071 0.0000 -0.7071 +vn 1.0000 0.0000 0.0000 +vn -1.0000 0.0000 0.0000 +vn -0.7071 0.0000 0.7071 +vn 0.0000 0.0000 1.0000 +vn -0.0000 0.0000 -1.0000 +vn 0.0000 1.0000 0.0000 +vn 0.0000 0.7071 0.7071 +vn 0.7071 0.7071 0.0000 +vn 0.0000 0.7071 -0.7071 +vn -0.7071 0.7071 0.0000 +vn -0.5774 0.5774 0.5774 +vn -0.5774 0.5774 -0.5774 +vn 0.5774 0.5774 -0.5774 +vn 0.5774 0.5774 0.5774 +vn 0.9239 0.0000 -0.3827 +vn 0.3827 0.0000 0.9239 +vn -0.9239 0.0000 0.3827 +vn -0.3827 0.0000 -0.9239 +vn 0.3827 0.0000 -0.9239 +vn 0.9239 0.0000 0.3827 +vn -0.3827 0.0000 0.9239 +vn -0.9239 0.0000 -0.3827 +s off +f 4/1/1 8/2/1 10/3/1 +f 7/4/2 6/5/2 5/6/2 +f 8/2/3 12/7/3 10/3/3 +f 3/8/4 12/9/4 7/10/4 +f 3/8/5 5/11/5 1/12/5 +f 5/13/6 11/14/6 1/15/6 +f 5/13/7 9/16/7 11/14/7 +f 2/17/8 9/18/8 6/19/8 +f 2/17/9 8/20/9 4/21/9 +f 10/3/10 16/22/10 4/1/10 +f 14/23/11 9/18/11 2/17/11 +f 15/24/12 12/9/12 3/8/12 +f 16/25/13 2/17/13 4/21/13 +f 13/26/14 3/8/14 1/12/14 +f 19/27/15 1/15/15 11/14/15 +f 17/28/16 11/14/16 9/16/16 +f 20/29/17 10/3/17 12/7/17 +f 22/30/18 23/31/18 21/32/18 +f 22/33/19 19/27/19 17/28/19 +f 24/34/20 14/23/20 16/25/20 +f 23/31/21 18/35/21 20/29/21 +f 21/36/22 15/24/22 13/26/22 +f 13/37/23 19/27/23 21/38/23 +f 15/24/24 23/39/24 20/40/24 +f 16/22/25 18/35/25 24/41/25 +f 14/23/26 22/42/26 17/43/26 +f 32/44/27 39/45/27 31/46/27 +f 30/47/28 37/48/28 29/49/28 +f 28/50/29 35/51/29 27/52/29 +f 26/53/30 33/54/30 25/55/30 +f 25/55/31 40/56/31 32/57/31 +f 31/46/32 38/58/32 30/59/32 +f 29/49/33 36/60/33 28/61/33 +f 27/52/34 34/62/34 26/63/34 +f 34/62/18 35/51/18 57/64/18 +f 48/65/17 42/66/17 43/67/17 +f 46/68/16 44/69/16 45/70/16 +f 41/71/18 46/72/18 42/66/18 +f 48/73/14 47/74/14 41/71/14 +f 42/75/13 45/76/13 43/77/13 +f 53/78/7 52/79/7 56/80/7 +f 55/81/13 52/79/13 51/82/13 +f 55/83/21 50/84/21 54/85/21 +f 54/85/14 49/86/14 53/87/14 +f 53/88/19 55/83/19 54/85/19 +f 39/45/18 57/64/18 38/58/18 +f 33/54/18 57/64/18 40/56/18 +f 37/48/18 57/64/18 36/60/18 +f 57/89/18 33/54/18 34/90/18 +f 38/91/18 57/89/18 37/48/18 +f 36/92/18 57/89/18 35/51/18 +f 40/93/18 57/89/18 39/45/18 +f 7/4/2 8/94/2 6/5/2 +f 8/2/3 7/4/3 12/7/3 +f 3/8/5 7/10/5 5/11/5 +f 5/13/7 6/95/7 9/16/7 +f 2/17/9 6/19/9 8/20/9 +f 10/3/10 18/35/10 16/22/10 +f 14/23/11 17/43/11 9/18/11 +f 15/24/12 20/40/12 12/9/12 +f 16/25/13 14/23/13 2/17/13 +f 13/26/14 15/24/14 3/8/14 +f 19/27/15 13/37/15 1/15/15 +f 17/28/16 19/27/16 11/14/16 +f 20/29/17 18/35/17 10/3/17 +f 22/30/18 24/96/18 23/31/18 +f 22/33/19 21/38/19 19/27/19 +f 24/34/20 22/42/20 14/23/20 +f 23/31/21 24/41/21 18/35/21 +f 21/36/22 23/39/22 15/24/22 +f 32/44/27 40/93/27 39/45/27 +f 30/47/28 38/91/28 37/48/28 +f 28/50/29 36/92/29 35/51/29 +f 26/53/30 34/90/30 33/54/30 +f 25/55/31 33/54/31 40/56/31 +f 31/46/32 39/45/32 38/58/32 +f 29/49/33 37/48/33 36/60/33 +f 27/52/34 35/51/34 34/62/34 +f 48/65/17 41/71/17 42/66/17 +f 46/68/16 47/97/16 44/69/16 +f 41/71/18 47/74/18 46/72/18 +f 48/73/14 44/98/14 47/74/14 +f 42/75/13 46/68/13 45/76/13 +f 53/78/7 49/99/7 52/79/7 +f 55/81/13 56/80/13 52/79/13 +f 55/83/21 51/100/21 50/84/21 +f 54/85/14 50/84/14 49/86/14 +f 53/88/19 56/101/19 55/83/19 diff --git a/src/main/resources/assets/hbm/textures/blocks/hev_battery.png b/src/main/resources/assets/hbm/textures/blocks/hev_battery.png new file mode 100644 index 0000000000000000000000000000000000000000..95eba4f4785efec0690fd7dc69d623697fd2363c GIT binary patch literal 382 zcmV-^0fGLBP)v8QxsCG6Ni+ zoHu-0Ym`zuJ-jse?rc4d