From 2307dedfe0db727072b9cccf5473e3190c31a3e9 Mon Sep 17 00:00:00 2001 From: IntegerLimit <103940576+IntegerLimit@users.noreply.github.com> Date: Sat, 18 Nov 2023 18:35:02 +1100 Subject: [PATCH] Cleanup + Excitation Coil Changes & Fixes Fixed it being upside down YOU CAN NOW PLACE IT ON YOUR HEAD WITHOUT COMMANDS! --- .../java/com/nomiceu/nomilabs/NomiLabs.java | 7 --- .../nomilabs/block/BlockExcitationCoil.java | 40 ++++++------- .../nomilabs/block/registry/LabsBlocks.java | 9 ++- .../nomiceu/nomilabs/event/CommonProxy.java | 2 - .../nomilabs/item/ItemExcitationCoil.java | 25 +++++++++ .../models/block/excitationcoil.json | 56 ++++++++++++++++--- .../models/item/excitationcoil.json | 39 +------------ 7 files changed, 97 insertions(+), 81 deletions(-) create mode 100644 src/main/java/com/nomiceu/nomilabs/item/ItemExcitationCoil.java diff --git a/src/main/java/com/nomiceu/nomilabs/NomiLabs.java b/src/main/java/com/nomiceu/nomilabs/NomiLabs.java index 2847b98b..3cfcfab9 100644 --- a/src/main/java/com/nomiceu/nomilabs/NomiLabs.java +++ b/src/main/java/com/nomiceu/nomilabs/NomiLabs.java @@ -2,13 +2,7 @@ import com.nomiceu.nomilabs.event.ClientProxy; import com.nomiceu.nomilabs.event.CommonProxy; -import com.nomiceu.nomilabs.item.registry.LabsItems; -import com.nomiceu.nomilabs.recipe.HandFramingRecipe; -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.item.crafting.IRecipe; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; @@ -16,7 +10,6 @@ import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.event.FMLServerStartingEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/src/main/java/com/nomiceu/nomilabs/block/BlockExcitationCoil.java b/src/main/java/com/nomiceu/nomilabs/block/BlockExcitationCoil.java index a16972e1..7dbe0be5 100644 --- a/src/main/java/com/nomiceu/nomilabs/block/BlockExcitationCoil.java +++ b/src/main/java/com/nomiceu/nomilabs/block/BlockExcitationCoil.java @@ -1,8 +1,7 @@ package com.nomiceu.nomilabs.block; -import net.minecraft.block.BlockDirectional; +import net.minecraft.block.*; import net.minecraft.block.material.Material; -import net.minecraft.block.SoundType; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.Mirror; @@ -21,41 +20,40 @@ @SuppressWarnings({"PointlessArithmeticExpression", "deprecation"}) public class BlockExcitationCoil extends BlockDirectional { - private static final AxisAlignedBB EAST_AABB = new AxisAlignedBB(0.0 / 16.0, 4.0 / 16.0, + private static final AxisAlignedBB WEST_AABB = new AxisAlignedBB(0.0 / 16.0, 4.0 / 16.0, 4.0 / 16.0, 9.0 / 16.0, 12.0 / 16.0, 12.0 / 16.0); - private static final AxisAlignedBB WEST_AABB = new AxisAlignedBB(7.0 / 16.0, 4.0 / 16.0, + private static final AxisAlignedBB EAST_AABB = new AxisAlignedBB(7.0 / 16.0, 4.0 / 16.0, 4.0 / 16.0, 16.0 / 16.0, 12.0 / 16.0, 12.0 / 16.0); - private static final AxisAlignedBB SOUTH_AABB = new AxisAlignedBB(4.0 / 16.0, 4.0 / 16.0, + private static final AxisAlignedBB NORTH_AABB = new AxisAlignedBB(4.0 / 16.0, 4.0 / 16.0, 0.0 / 16.0, 12.0 / 16.0, 12.0 / 16.0, 9.0 / 16.0); - private static final AxisAlignedBB NORTH_AABB = new AxisAlignedBB(4.0 / 16.0, 4.0 / 16.0, + private static final AxisAlignedBB SOUTH_AABB = new AxisAlignedBB(4.0 / 16.0, 4.0 / 16.0, 7.0 / 16.0, 12.0 / 16.0, 12.0 / 16.0, 16.0 / 16.0); - private static final AxisAlignedBB UP_AABB = new AxisAlignedBB(4.0 / 16.0, 0.0 / 16.0, + private static final AxisAlignedBB DOWN_AABB = new AxisAlignedBB(4.0 / 16.0, 0.0 / 16.0, 4.0 / 16.0, 12.0 / 16.0, 9.0 / 16.0, 12.0 / 16.0); - private static final AxisAlignedBB DOWN_AABB = new AxisAlignedBB(4.0 / 16.0, 7.0 / 16.0, + private static final AxisAlignedBB UP_AABB = new AxisAlignedBB(4.0 / 16.0, 7.0 / 16.0, 4.0 / 16.0, 12.0 / 16.0, 16.0 / 16.0, 12.0 / 16.0); public BlockExcitationCoil(ResourceLocation rl, CreativeTabs tab) { super(Material.IRON); fullBlock = false; - setSoundType(SoundType.METAL); - setCreativeTab(tab); - setRegistryName(rl); - setHardness(5.0F); - setResistance(5.0F); - setLightLevel(1.0F); - setHarvestLevel("pickaxe", 2); - + this.setSoundType(SoundType.METAL); + this.setCreativeTab(tab); + this.setRegistryName(rl); + this.setHardness(5.0F); + this.setResistance(5.0F); + this.setLightLevel(1.0F); + this.setHarvestLevel("pickaxe", 2); this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.UP)); } @@ -107,9 +105,9 @@ public boolean isNormalCube(@NotNull IBlockState state, @NotNull IBlockAccess wo } @Override - public @NotNull BlockFaceShape getBlockFaceShape(@NotNull IBlockAccess worldIn, @NotNull IBlockState state, @NotNull BlockPos pos, EnumFacing face) { + public @NotNull BlockFaceShape getBlockFaceShape(@NotNull IBlockAccess worldIn, @NotNull IBlockState state, @NotNull BlockPos pos, @NotNull EnumFacing face) { state = this.getActualState(state, worldIn, pos); - return state.getValue(FACING) == face.getOpposite() ? BlockFaceShape.SOLID : BlockFaceShape.UNDEFINED; + return state.getValue(FACING) == face ? BlockFaceShape.SOLID : BlockFaceShape.UNDEFINED; } @Override @@ -120,15 +118,13 @@ public boolean doesSideBlockRendering(@NotNull IBlockState state, @NotNull IBloc @Override public @NotNull IBlockState getStateForPlacement(@NotNull World worldIn, @NotNull BlockPos pos, @NotNull EnumFacing facing, float hitX, float hitY, float hitZ, int meta, @NotNull EntityLivingBase placer) { - return this.getDefaultState().withProperty(FACING, EnumFacing.getDirectionFromEntityLiving(pos, placer)); + return this.getDefaultState().withProperty(FACING, EnumFacing.getDirectionFromEntityLiving(pos, placer).getOpposite()); } @Override public @NotNull IBlockState getStateFromMeta(int meta) { - IBlockState blockState = this.getDefaultState(); - blockState = blockState.withProperty(FACING, EnumFacing.byIndex(meta)); - return blockState; + return this.getDefaultState().withProperty(FACING, EnumFacing.byIndex(meta)); } @Override diff --git a/src/main/java/com/nomiceu/nomilabs/block/registry/LabsBlocks.java b/src/main/java/com/nomiceu/nomilabs/block/registry/LabsBlocks.java index 17d1f997..d32c6f33 100644 --- a/src/main/java/com/nomiceu/nomilabs/block/registry/LabsBlocks.java +++ b/src/main/java/com/nomiceu/nomilabs/block/registry/LabsBlocks.java @@ -3,6 +3,7 @@ import com.nomiceu.nomilabs.block.*; import com.nomiceu.nomilabs.item.ItemBlockBase; import com.nomiceu.nomilabs.creativetab.registry.LabsCreativeTabs; +import com.nomiceu.nomilabs.item.ItemExcitationCoil; import com.nomiceu.nomilabs.item.registry.LabsItems; import net.minecraft.block.Block; import net.minecraft.block.SoundType; @@ -55,8 +56,9 @@ public static void preInit() { EnumRarity.COMMON, 64); /* Custom Behaviour Blocks */ - EXCITATION_COIL = createBlock(new BlockExcitationCoil(makeCTName("excitationcoil"), LabsCreativeTabs.TAB_NOMI_LABS), - EnumRarity.UNCOMMON, 64); + // Register Item separately to allow putting excitation coil on head + EXCITATION_COIL = createBlockWithoutItem(new BlockExcitationCoil(makeCTName("excitationcoil"), LabsCreativeTabs.TAB_NOMI_LABS)); + LabsItems.createItem(new ItemExcitationCoil(EXCITATION_COIL)); DUST = createBlock(new BlockDust(makeCTName("block_dust"), LabsCreativeTabs.TAB_NOMI_LABS), EnumRarity.COMMON, 64); } @@ -74,8 +76,9 @@ public static T createBlock(T block, @NotNull IRarity rarity, return block; } - public static void createBlockWithoutItem(T block) { + public static T createBlockWithoutItem(T block) { BLOCKS.add(block); + return block; } private static void registerBlock(Block block, IForgeRegistry registry) { diff --git a/src/main/java/com/nomiceu/nomilabs/event/CommonProxy.java b/src/main/java/com/nomiceu/nomilabs/event/CommonProxy.java index 4a0d10df..c107770a 100644 --- a/src/main/java/com/nomiceu/nomilabs/event/CommonProxy.java +++ b/src/main/java/com/nomiceu/nomilabs/event/CommonProxy.java @@ -10,14 +10,12 @@ import com.nomiceu.nomilabs.gregtech.material.registry.LabsMaterials; import com.nomiceu.nomilabs.gregtech.multiblock.registry.LabsMultiblocks; import com.nomiceu.nomilabs.item.registry.LabsItems; -import com.nomiceu.nomilabs.recipe.GreenhouseTestRecipes; import com.nomiceu.nomilabs.recipe.HandFramingRecipe; import com.nomiceu.nomilabs.util.LabsNames; import gregtech.api.unification.material.event.MaterialEvent; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.crafting.IRecipe; -import net.minecraft.util.ResourceLocation; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.EventPriority; diff --git a/src/main/java/com/nomiceu/nomilabs/item/ItemExcitationCoil.java b/src/main/java/com/nomiceu/nomilabs/item/ItemExcitationCoil.java new file mode 100644 index 00000000..802d3f71 --- /dev/null +++ b/src/main/java/com/nomiceu/nomilabs/item/ItemExcitationCoil.java @@ -0,0 +1,25 @@ +package com.nomiceu.nomilabs.item; + +import net.minecraft.block.Block; +import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Objects; + +public class ItemExcitationCoil extends ItemBlock { + public ItemExcitationCoil(Block block) { + super(block); + setRegistryName(Objects.requireNonNull(block.getRegistryName())); + setCreativeTab(block.getCreativeTab()); + setMaxStackSize(64); + } + + @Nullable + @Override + public EntityEquipmentSlot getEquipmentSlot(@NotNull ItemStack stack) { + return EntityEquipmentSlot.HEAD; + } +} diff --git a/src/main/resources/assets/contenttweaker/models/block/excitationcoil.json b/src/main/resources/assets/contenttweaker/models/block/excitationcoil.json index d30a9efb..37f19df8 100644 --- a/src/main/resources/assets/contenttweaker/models/block/excitationcoil.json +++ b/src/main/resources/assets/contenttweaker/models/block/excitationcoil.json @@ -1,13 +1,51 @@ { + "parent": "block/block", "textures": { "particle": "thermalexpansion:blocks/dynamo/dynamo_coil_redstone_anim", "tex": "thermalexpansion:blocks/dynamo/dynamo_coil_redstone_anim", "base": "minecraft:blocks/concrete_white" }, + "display": { + "gui": { + "rotation": [ 30, 225, 0 ], + "translation": [ 0, 3, 0], + "scale":[ 1, 1, 1 ] + }, + "ground": { + "rotation": [ 0, 0, 0 ], + "translation": [ 0, 3, 0], + "scale":[ 0.5, 0.5, 0.5 ] + }, + "fixed": { + "rotation": [ 0, 0, 0 ], + "translation": [ 0, 0, 0], + "scale":[ 1, 1, 1 ] + }, + "thirdperson_righthand": { + "rotation": [ 75, 45, 0 ], + "translation": [ 0, 3, 1.5], + "scale": [ 0.6, 0.6, 0.6 ] + }, + "firstperson_righthand": { + "rotation": [ 0, 45, 0 ], + "translation": [ 0, 2, 0 ], + "scale": [ 0.8, 0.8, 0.8 ] + }, + "firstperson_lefthand": { + "rotation": [ 0, 225, 0 ], + "translation": [ 0, 2, 0 ], + "scale": [ 0.8, 0.8, 0.8 ] + }, + "head": { + "rotation": [ 0, 0, 0 ], + "translation": [ 0, 18, 0], + "scale":[ 1.5, 1.5, 1.5 ] + } + }, "elements": [ { - "from": [ 3, 0, 3 ], - "to": [ 13, 1, 13 ], + "from": [ 3, 15, 3 ], + "to": [ 13, 16, 13 ], "faces": { "down": { "texture": "#base", "cullface": "down" }, "up": { "texture": "#base" }, @@ -18,14 +56,14 @@ } }, { - "from": [ 4, 1, 4 ], - "to": [ 12, 9, 12 ], + "from": [ 4, 7, 4 ], + "to": [ 12, 15, 12 ], "faces": { - "up": { "uv": [ 4, 0, 8, 4 ], "texture": "#tex" }, - "north": { "uv": [ 0, 4, 4, 8 ], "texture": "#tex" }, - "east": { "uv": [ 4, 4, 8, 8 ], "texture": "#tex" }, - "south": { "uv": [ 8, 4, 12, 8 ], "texture": "#tex" }, - "west": { "uv": [ 12, 4, 16, 8 ], "texture": "#tex" } + "down": { "uv": [ 8, 4, 4, 0 ], "texture": "#tex" }, + "north": { "uv": [ 4, 8, 0, 4 ], "texture": "#tex" }, + "east": { "uv": [ 8, 8, 4, 4 ], "texture": "#tex" }, + "south": { "uv": [ 12, 8, 8, 4 ], "texture": "#tex" }, + "west": { "uv": [ 16, 8, 12, 4 ], "texture": "#tex" } } } ] diff --git a/src/main/resources/assets/contenttweaker/models/item/excitationcoil.json b/src/main/resources/assets/contenttweaker/models/item/excitationcoil.json index 99b0f6fe..f5eb43fc 100644 --- a/src/main/resources/assets/contenttweaker/models/item/excitationcoil.json +++ b/src/main/resources/assets/contenttweaker/models/item/excitationcoil.json @@ -1,40 +1,3 @@ { - "parent": "contenttweaker:block/excitationcoil", - "display": { - "gui": { - "rotation": [ 30, 225, 0 ], - "translation": [ 0, 3, 0], - "scale":[ 1.0, 1.0, 1.0 ] - }, - "ground": { - "rotation": [ 0, 0, 0 ], - "translation": [ 0, 3, 0], - "scale":[ 0.50, 0.50, 0.50 ] - }, - "fixed": { - "rotation": [ 0, 0, 0 ], - "translation": [ 0, 1.5, 0], - "scale":[ 1.0, 1.0, 1.0 ] - }, - "thirdperson_righthand": { - "rotation": [ 75, 45, 0 ], - "translation": [ 0, 3, 0], - "scale": [ 0.50, 0.50, 0.50 ] - }, - "firstperson_righthand": { - "rotation": [ 0, 45, 0 ], - "translation": [ 0, 1.5, 0 ], - "scale": [ 0.80, 0.80, 0.80 ] - }, - "firstperson_lefthand": { - "rotation": [ 0, 225, 0 ], - "translation": [ 0, 1.5, 0 ], - "scale": [ 0.80, 0.80, 0.80 ] - }, - "head": { - "rotation": [ 0, 0, 0 ], - "translation": [ 0, 20, 0], - "scale":[ 1.5, 1.5, 1.5 ] - } - } + "parent": "contenttweaker:block/excitationcoil" }