Skip to content

Commit

Permalink
Merge pull request #1934 from MellowArpeggiation/moige
Browse files Browse the repository at this point in the history
NBT Structures + new Meteor Dungeon + bonus stuff
  • Loading branch information
HbmMods authored Feb 10, 2025
2 parents 27afb9e + 98a3345 commit 6043d1d
Show file tree
Hide file tree
Showing 116 changed files with 4,814 additions and 2,074 deletions.
52 changes: 37 additions & 15 deletions src/main/java/com/hbm/blocks/BlockDummyable.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
import com.hbm.interfaces.ICopiable;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.IPersistentNBT;
import com.hbm.world.gen.INBTTransformable;

import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.RenderGlobal;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
Expand All @@ -32,7 +35,7 @@
import java.util.List;
import java.util.Random;

public abstract class BlockDummyable extends BlockContainer implements ICustomBlockHighlight, ICopiable {
public abstract class BlockDummyable extends BlockContainer implements ICustomBlockHighlight, ICopiable, INBTTransformable {

public BlockDummyable(Material mat) {
super(mat);
Expand Down Expand Up @@ -116,7 +119,7 @@ public int[] findCore(World world, int x, int y, int z) {
return findCoreRec(world, x, y, z);
}

List<ThreeInts> positions = new ArrayList();
List<ThreeInts> positions = new ArrayList<>();

public int[] findCoreRec(World world, int x, int y, int z) {

Expand Down Expand Up @@ -216,11 +219,6 @@ public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase p
super.onBlockPlacedBy(world, x, y, z, player, itemStack);
}

/*@Override
public void onBlockAdded(World world, int x, int y, int z) {
lastBlockSet = new BlockPos(x, y, z);
}*/

/**
* A bit more advanced than the dir modifier, but it is important that the resulting direction meta is in the core range.
* Using the "extra" metas is technically possible but requires a bit of tinkering, e.g. preventing a recursive loop
Expand Down Expand Up @@ -267,9 +265,9 @@ public void makeExtra(World world, int x, int y, int z) {
return;

// world.setBlockMetadataWithNotify(x, y, z, meta + extra, 3);
this.safeRem = true;
safeRem = true;
world.setBlock(x, y, z, this, meta + extra, 3);
this.safeRem = false;
safeRem = false;
}

public void removeExtra(World world, int x, int y, int z) {
Expand All @@ -283,9 +281,9 @@ public void removeExtra(World world, int x, int y, int z) {
return;

// world.setBlockMetadataWithNotify(x, y, z, meta + extra, 3);
this.safeRem = true;
safeRem = true;
world.setBlock(x, y, z, this, meta - extra, 3);
this.safeRem = false;
safeRem = false;
}

// checks if the dummy metadata is within the extra range
Expand Down Expand Up @@ -423,8 +421,9 @@ public boolean useDetailedHitbox() {
return !bounding.isEmpty();
}

public List<AxisAlignedBB> bounding = new ArrayList();
public List<AxisAlignedBB> bounding = new ArrayList<>();

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB entityBounding, List list, Entity entity) {

Expand All @@ -443,7 +442,7 @@ public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAligne
z = pos[2];

for(AxisAlignedBB aabb :this.bounding) {
AxisAlignedBB boxlet = getAABBRotationOffset(aabb, x + 0.5, y, z + 0.5, ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z) - this.offset).getRotation(ForgeDirection.UP));
AxisAlignedBB boxlet = getAABBRotationOffset(aabb, x + 0.5, y, z + 0.5, ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z) - offset).getRotation(ForgeDirection.UP));

if(entityBounding.intersectsWith(boxlet)) {
list.add(boxlet);
Expand Down Expand Up @@ -504,7 +503,7 @@ public void drawHighlight(DrawBlockHighlightEvent event, World world, int x, int
int meta = world.getBlockMetadata(x, y, z);

ICustomBlockHighlight.setup();
for(AxisAlignedBB aabb : this.bounding) event.context.drawOutlinedBoundingBox(getAABBRotationOffset(aabb.expand(exp, exp, exp), 0, 0, 0, ForgeDirection.getOrientation(meta - offset).getRotation(ForgeDirection.UP)).getOffsetBoundingBox(x - dX + 0.5, y - dY, z - dZ + 0.5), -1);
for(AxisAlignedBB aabb : this.bounding) RenderGlobal.drawOutlinedBoundingBox(getAABBRotationOffset(aabb.expand(exp, exp, exp), 0, 0, 0, ForgeDirection.getOrientation(meta - offset).getRotation(ForgeDirection.UP)).getOffsetBoundingBox(x - dX + 0.5, y - dY, z - dZ + 0.5), -1);
ICustomBlockHighlight.cleanup();
}

Expand Down Expand Up @@ -534,4 +533,27 @@ public String[] infoForDisplay(World world, int x, int y, int z) {
return ((ICopiable) tile).infoForDisplay(world, x, y, z);
return null;
}
}

@Override
public int transformMeta(int meta, int coordBaseMode) {
boolean isOffset = meta >= 12; // squishing causes issues
boolean isExtra = !isOffset && meta >= extra;

if(isOffset) {
meta -= offset;
} else if(isExtra) {
meta -= extra;
}

meta = INBTTransformable.transformMetaDeco(meta, coordBaseMode);

if(isOffset) {
meta += offset;
} else if(isExtra) {
meta += extra;
}

return meta;
}

}
23 changes: 23 additions & 0 deletions src/main/java/com/hbm/blocks/IBlockSideRotation.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,27 @@ public interface IBlockSideRotation {
public static int getRenderType() {
return renderID;
}

// 0 1 3 2 becomes 0 2 3 1
// I want to smoke that swedish kush because it clearly makes you fucking stupid
public static int topToBottom(int topRotation) {
switch(topRotation) {
case 1: return 2;
case 2: return 1;
default: return topRotation;
}
}

public static boolean isOpposite(int from, int to) {
switch(from) {
case 0: return to == 1;
case 1: return to == 0;
case 2: return to == 3;
case 3: return to == 2;
case 4: return to == 5;
case 5: return to == 4;
default: return false;
}
}

}
21 changes: 19 additions & 2 deletions src/main/java/com/hbm/blocks/ModBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import net.minecraft.block.BlockFalling;
import net.minecraft.block.material.*;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -603,6 +604,7 @@ public static void mainRegistry()
public static Block spikes;

public static Block charger;
public static Block refueler;

public static Block tesla;

Expand Down Expand Up @@ -1227,6 +1229,11 @@ public Material setImmovableMobility() { //override access modifier
public static Block pink_double_slab;
public static Block pink_stairs;

// NBT Structure wand blocks
public static Block wand_air;
public static Block wand_loot;
public static Block wand_jigsaw;

public static Material materialGas = new MaterialGas();

private static void initializeBlock() {
Expand Down Expand Up @@ -1653,7 +1660,7 @@ private static void initializeBlock() {
plant_dead = new BlockDeadPlant().setBlockName("plant_dead").setCreativeTab(MainRegistry.blockTab).setStepSound(Block.soundTypeGrass).setHardness(0.0F);
reeds = new BlockReeds().setBlockName("plant_reeds").setCreativeTab(MainRegistry.blockTab).setStepSound(Block.soundTypeGrass).setHardness(0.0F);
vine_phosphor = new BlockHangingVine(thick_foliage).setBlockName("vine_phosphor").setCreativeTab(MainRegistry.blockTab).setStepSound(Block.soundTypeGrass).setHardness(0.5F);

waste_earth = new WasteEarth(Material.ground, true).setBlockName("waste_earth").setStepSound(Block.soundTypeGrass).setCreativeTab(MainRegistry.blockTab).setHardness(0.6F).setBlockTextureName(RefStrings.MODID + ":waste_earth");
waste_mycelium = new WasteEarth(Material.ground, true).setBlockName("waste_mycelium").setStepSound(Block.soundTypeGrass).setLightLevel(1F).setCreativeTab(MainRegistry.blockTab).setHardness(0.6F).setBlockTextureName(RefStrings.MODID + ":waste_mycelium_side");
waste_trinitite = new BlockOre(Material.sand).noFortune().setBlockName("waste_trinitite").setStepSound(Block.soundTypeSand).setCreativeTab(MainRegistry.blockTab).setHardness(0.5F).setResistance(2.5F).setBlockTextureName(RefStrings.MODID + ":waste_trinitite");
Expand Down Expand Up @@ -1835,7 +1842,7 @@ private static void initializeBlock() {
pa_quadrupole = new BlockPAQuadrupole().setStepSound(Block.soundTypeMetal).setBlockName("pa_quadrupole").setHardness(5.0F).setResistance(10.0F);
pa_dipole = new BlockPADipole().setStepSound(Block.soundTypeMetal).setBlockName("pa_dipole").setHardness(5.0F).setResistance(10.0F);
pa_detector = new BlockPADetector().setStepSound(Block.soundTypeMetal).setBlockName("pa_detector").setHardness(5.0F).setResistance(10.0F);

machine_electric_furnace_off = new MachineElectricFurnace(false).setBlockName("machine_electric_furnace_off").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
machine_electric_furnace_on = new MachineElectricFurnace(true).setBlockName("machine_electric_furnace_on").setHardness(5.0F).setLightLevel(1.0F).setResistance(10.0F);
machine_arc_furnace_off = new MachineArcFurnace(false).setBlockName("machine_arc_furnace_off").setHardness(5.0F).setResistance(10.0F);
Expand Down Expand Up @@ -2068,6 +2075,7 @@ private static void initializeBlock() {
spikes = new Spikes(Material.iron).setBlockName("spikes").setHardness(2.5F).setResistance(5.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":spikes");

charger = new Charger(Material.iron).setBlockName("charger").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":block_steel");
refueler = new BlockRefueler(Material.iron).setBlockName("refueler").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":block_steel");

tesla = new MachineTesla(Material.iron).setBlockName("tesla").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":tesla");

Expand Down Expand Up @@ -2352,6 +2360,10 @@ private static void initializeBlock() {
pink_slab = new BlockPinkSlab(false, Material.wood).setBlockName("pink_slab").setStepSound(Block.soundTypeWood).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":pink_planks");
pink_double_slab = new BlockPinkSlab(true, Material.wood).setBlockName("pink_double_slab").setStepSound(Block.soundTypeWood).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":pink_planks");
pink_stairs = new BlockGenericStairs(pink_planks, 0).setBlockName("pink_stairs").setStepSound(Block.soundTypeWood).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":pink_planks");

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");
}

private static void registerBlock() {
Expand Down Expand Up @@ -2709,6 +2721,7 @@ private static void registerBlock() {

//Charger
GameRegistry.registerBlock(charger, charger.getUnlocalizedName());
GameRegistry.registerBlock(refueler, refueler.getUnlocalizedName());
//GameRegistry.registerBlock(floodlight, floodlight.getUnlocalizedName());

//Decoration Blocks
Expand Down Expand Up @@ -3472,6 +3485,10 @@ private static void registerBlock() {
GameRegistry.registerBlock(pink_slab, pink_slab.getUnlocalizedName());
GameRegistry.registerBlock(pink_double_slab, pink_double_slab.getUnlocalizedName());
GameRegistry.registerBlock(pink_stairs, pink_stairs.getUnlocalizedName());

register(wand_air);
register(wand_loot);
register(wand_jigsaw);
}

private static void register(Block b) {
Expand Down
19 changes: 16 additions & 3 deletions src/main/java/com/hbm/blocks/generic/BlockBobble.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import com.hbm.items.special.ItemPlasticScrap.ScrapType;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.IGUIProvider;
import com.hbm.world.gen.INBTTileEntityTransformable;
import com.hbm.world.gen.INBTTransformable;

import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
Expand Down Expand Up @@ -31,7 +34,7 @@
import java.util.List;
import java.util.Random;

public class BlockBobble extends BlockContainer implements IGUIProvider {
public class BlockBobble extends BlockContainer implements IGUIProvider, INBTTransformable {

public BlockBobble() {
super(Material.iron);
Expand Down Expand Up @@ -136,12 +139,17 @@ public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y,
return AxisAlignedBB.getBoundingBox(x + this.minX, y + this.minY, z + this.minZ, x + this.maxX, y + this.maxY, z + this.maxZ);
}

@Override
public int transformMeta(int meta, int coordBaseMode) {
return (meta + coordBaseMode * 4) % 16;
}

@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityBobble();
}

public static class TileEntityBobble extends TileEntity {
public static class TileEntityBobble extends TileEntity implements INBTTileEntityTransformable {

public BobbleType type = BobbleType.NONE;

Expand Down Expand Up @@ -173,6 +181,11 @@ public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setByte("type", (byte) type.ordinal());
}

@Override
public void transformTE(World world, int coordBaseMode) {
type = BobbleType.values()[world.rand.nextInt(BobbleType.values().length - 1) + 1];
}
}

public static enum BobbleType {
Expand Down Expand Up @@ -200,7 +213,7 @@ public static enum BobbleType {
CIRNO( "Cirno", "Cirno", "the only multi layered skin i had", "No brain. Head empty.", true, ScrapType.BOARD_BLANK),
MICROWAVE( "Microwave", "Microwave", "OC Compatibility and massive RBMK/packet optimizations", "they call me the food heater$john optimization", true, ScrapType.BOARD_CONVERTER),
PEEP( "Peep", "LePeeperSauvage", "Coilgun, Leadburster and Congo Lake models, BDCL QC", "Fluffy ears can't hide in ash, nor snow.", true, ScrapType.CARD_BOARD),
MELLOW( "MELLOWARPEGGIATION", "Mellow", "Industrial lighting, animation tools", "Make something cool now, ask for permission later.", true, ScrapType.CARD_PROCESSOR);
MELLOW( "MELLOWARPEGGIATION", "Mellow", "NBT Structures, industrial lighting, animation tools", "Make something cool now, ask for permission later.", true, ScrapType.CARD_PROCESSOR);

public String name; //the title of the tooltip
public String label; //the name engraved in the socket
Expand Down
23 changes: 15 additions & 8 deletions src/main/java/com/hbm/blocks/generic/BlockDecoCRT.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.hbm.blocks.BlockMulti;
import com.hbm.lib.RefStrings;
import com.hbm.world.gen.INBTTransformable;

import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.relauncher.Side;
Expand All @@ -14,7 +15,7 @@
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

public class BlockDecoCRT extends BlockMulti {
public class BlockDecoCRT extends BlockMulti implements INBTTransformable {

protected String[] variants = new String[] {"crt_clean", "crt_broken", "crt_blinking", "crt_bsod"};
@SideOnly(Side.CLIENT) protected IIcon[] icons;
Expand All @@ -24,17 +25,17 @@ public BlockDecoCRT(Material 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;
Expand All @@ -45,12 +46,12 @@ public boolean renderAsNormalBlock() {
public void registerBlockIcons(IIconRegister reg) {
super.registerBlockIcons(reg);
this.icons = new IIcon[variants.length];

for(int i = 0; i < variants.length; i++) {
this.icons[i] = reg.registerIcon(RefStrings.MODID + ":" + variants[i]);
}
}

@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
Expand All @@ -61,7 +62,7 @@ public IIcon getIcon(int side, int meta) {
public int damageDropped(int meta) {
return (Math.abs(meta) % 16) / 4;
}

@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
Expand All @@ -73,4 +74,10 @@ public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase p
public int getSubCount() {
return 4;
}
}

@Override
public int transformMeta(int meta, int coordBaseMode) {
return INBTTransformable.transformMetaDecoModel(meta, coordBaseMode);
}

}
Loading

0 comments on commit 6043d1d

Please sign in to comment.