Skip to content

Commit

Permalink
Cleanup + Excitation Coil Changes & Fixes
Browse files Browse the repository at this point in the history
Fixed it being upside down
YOU CAN NOW PLACE IT ON YOUR HEAD WITHOUT COMMANDS!
  • Loading branch information
IntegerLimit committed Nov 18, 2023
1 parent 7d0195b commit 2307ded
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 81 deletions.
7 changes: 0 additions & 7 deletions src/main/java/com/nomiceu/nomilabs/NomiLabs.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,14 @@

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;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
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;

Expand Down
40 changes: 18 additions & 22 deletions src/main/java/com/nomiceu/nomilabs/block/BlockExcitationCoil.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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));
}

Expand Down Expand 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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand All @@ -74,8 +76,9 @@ public static <T extends Block> T createBlock(T block, @NotNull IRarity rarity,
return block;
}

public static <T extends Block> void createBlockWithoutItem(T block) {
public static <T extends Block> T createBlockWithoutItem(T block) {
BLOCKS.add(block);
return block;
}

private static void registerBlock(Block block, IForgeRegistry<Block> registry) {
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/nomiceu/nomilabs/event/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/com/nomiceu/nomilabs/item/ItemExcitationCoil.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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" },
Expand All @@ -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" }
}
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
}

0 comments on commit 2307ded

Please sign in to comment.