Jump to content

Recommended Posts

Posted (edited)

So I Recently Started Modding, After Finally Being Able To Learn Java, And Everything's Been Going Fine So Far. But When I Tried To Make My Fence Gate, I Can't Seem To Get It To Render. I See A Missing Variant Exception But My Blockstate File Is Pretty Much The Same As The Normal Fence Gate Blockstate File. Can Anyone Find Out What I Did Wrong So I Can Render My Fence Gate?

 

Edit: Forgot To Put My class And json

 

MasonwoodFenceGate.java

package com.emerald.moreOres.blocks.fences;

import javax.annotation.Nullable;

import com.emerald.moreOres.BlockList;
import com.emerald.moreOres.MoreOres;

import net.minecraft.block.Block;
import net.minecraft.block.BlockFence;
import net.minecraft.block.BlockHorizontal;
import net.minecraft.block.BlockWall;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.Mirror;
import net.minecraft.util.Rotation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class MasonwoodFenceGate extends BlockHorizontal {
	
	public static final PropertyBool OPEN = PropertyBool.create("open");
	public static final PropertyBool POWERED = PropertyBool.create("powered");
	public static final PropertyBool IN_WALL = PropertyBool.create("in_wall");
	protected static final AxisAlignedBB AABB_COLLIDE_ZAXIS = new AxisAlignedBB(0.0D, 0.0D, 0.375D, 1.0D, 1.0D, 0.625D);
	protected static final AxisAlignedBB AABB_COLLIDE_XAXIS = new AxisAlignedBB(0.375D, 0.0D, 0.0D, 0.625D, 1.0D, 1.0D);
	protected static final AxisAlignedBB AABB_COLLIDE_ZAXIS_INWALL = new AxisAlignedBB(0.0D, 0.0D, 0.375D, 1.0D, 0.8125D, 0.625D);
	protected static final AxisAlignedBB AABB_COLLIDE_XAXIS_INWALL = new AxisAlignedBB(0.375D, 0.0D, 0.0D, 0.625D, 0.8125D, 1.0D);
	protected static final AxisAlignedBB AABB_CLOSED_SELECTED_ZAXIS = new AxisAlignedBB(0.0D, 0.0D, 0.375D, 1.0D, 1.5D, 0.625D);
	protected static final AxisAlignedBB AABB_CLOSED_SELECTED_XAXIS = new AxisAlignedBB(0.375D, 0.0D, 0.0D, 0.625D, 1.5D, 1.0D);
	
	public MasonwoodFenceGate() {
		
		//Material
		super(Material.WOOD, Material.WOOD.getMaterialMapColor());
		
		//Default State
		setDefaultState(this.blockState.getBaseState().withProperty(OPEN, Boolean.valueOf(false)).withProperty(POWERED, Boolean.valueOf(false)).withProperty(IN_WALL, Boolean.valueOf(false)));
		
		//Setting Registry Name
		setUnlocalizedName(BlockList.BList.MASONWOOD_FENCE_GATE.getUnlocalizedName());
		setRegistryName(BlockList.BList.MASONWOOD_FENCE_GATE.getRegistryName());
		
		//Creative Tab
		setCreativeTab(MoreOres.tabEmeraldsBlocks);
				
		//Footstep Sound
		setSoundType(SoundType.WOOD);
		
		//Hardness
		setHardness(5.0F);
				
		//Explosion Resistance
		setResistance(75.0F);
		
	}
	
	public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
		state = this.getActualState(state, source, pos);
		return ((Boolean) state.getValue(IN_WALL)).booleanValue()
				? (((EnumFacing) state.getValue(FACING)).getAxis() == EnumFacing.Axis.X ? AABB_COLLIDE_XAXIS_INWALL
						: AABB_COLLIDE_ZAXIS_INWALL)
				: (((EnumFacing) state.getValue(FACING)).getAxis() == EnumFacing.Axis.X ? AABB_COLLIDE_XAXIS
						: AABB_COLLIDE_ZAXIS);
	}
	
	public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
		EnumFacing.Axis enumfacing$axis = ((EnumFacing) state.getValue(FACING)).getAxis();

		if (enumfacing$axis == EnumFacing.Axis.Z
				&& (canFenceGateConnectTo(worldIn, pos, EnumFacing.WEST)
						|| canFenceGateConnectTo(worldIn, pos, EnumFacing.EAST))
				|| enumfacing$axis == EnumFacing.Axis.X && (canFenceGateConnectTo(worldIn, pos, EnumFacing.NORTH)
						|| canFenceGateConnectTo(worldIn, pos, EnumFacing.SOUTH))) {
			state = state.withProperty(IN_WALL, Boolean.valueOf(true));
		}

		return state;
	}
	
	public IBlockState withRotation(IBlockState state, Rotation rot) {
		return state.withProperty(FACING, rot.rotate((EnumFacing) state.getValue(FACING)));
	}
	
	public IBlockState withMirror(IBlockState state, Mirror mirrorIn) {
		return state.withRotation(mirrorIn.toRotation((EnumFacing) state.getValue(FACING)));
	}
	
	public boolean canPlaceBlockAt(World worldIn, BlockPos pos) {
		return worldIn.getBlockState(pos.down()).getMaterial().isSolid() ? super.canPlaceBlockAt(worldIn, pos) : false;
	}
	
	@Nullable
	public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) {
		return ((Boolean) blockState.getValue(OPEN)).booleanValue() ? NULL_AABB
				: (((EnumFacing) blockState.getValue(FACING)).getAxis() == EnumFacing.Axis.Z
						? AABB_CLOSED_SELECTED_ZAXIS : AABB_CLOSED_SELECTED_XAXIS);
	}
	
	public boolean isOpaqueCube(IBlockState state) {
		return false;
	}
	
	public boolean isFullCube(IBlockState state) {
		return false;
	}
	
	public boolean isPassable(IBlockAccess worldIn, BlockPos pos) {
		return ((Boolean) worldIn.getBlockState(pos).getValue(OPEN)).booleanValue();
	}
	
	public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY,
			float hitZ, int meta, EntityLivingBase placer) {
		boolean flag = worldIn.isBlockPowered(pos);
		return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing())
				.withProperty(OPEN, Boolean.valueOf(flag)).withProperty(POWERED, Boolean.valueOf(flag))
				.withProperty(IN_WALL, Boolean.valueOf(false));
	}
	
	public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
			EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
		if (((Boolean) state.getValue(OPEN)).booleanValue()) {
			state = state.withProperty(OPEN, Boolean.valueOf(false));
			worldIn.setBlockState(pos, state, 10);
		} else {
			EnumFacing enumfacing = EnumFacing.fromAngle((double) playerIn.rotationYaw);

			if (state.getValue(FACING) == enumfacing.getOpposite()) {
				state = state.withProperty(FACING, enumfacing);
			}

			state = state.withProperty(OPEN, Boolean.valueOf(true));
			worldIn.setBlockState(pos, state, 10);
		}

		worldIn.playSound(playerIn, pos, ((Boolean) state.getValue(OPEN)).booleanValue()
				
				//Open And Close Sound
				? SoundEvents.BLOCK_FENCE_GATE_OPEN : SoundEvents.BLOCK_FENCE_GATE_CLOSE, SoundCategory.BLOCKS, 1.0F, 1.0F);
		
		return true;
	}
	
	public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) {
		if (!worldIn.isRemote) {
			boolean flag = worldIn.isBlockPowered(pos);

			if (((Boolean) state.getValue(POWERED)).booleanValue() != flag) {
				worldIn.setBlockState(pos,
						state.withProperty(POWERED, Boolean.valueOf(flag)).withProperty(OPEN, Boolean.valueOf(flag)),
						2);

				if (((Boolean) state.getValue(OPEN)).booleanValue() != flag) {
					worldIn.playSound(null, pos,
							
							//Open And Close Sound
							flag ? SoundEvents.BLOCK_FENCE_GATE_OPEN : SoundEvents.BLOCK_FENCE_GATE_CLOSE, SoundCategory.BLOCKS, 1.0F, 1.0F);
				}
			}
		}
	}
	
	@SideOnly(Side.CLIENT)
	public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos,
			EnumFacing side) {
		return true;
	}
	
	public IBlockState getStateFromMeta(int meta) {
		return this.getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta))
				.withProperty(OPEN, Boolean.valueOf((meta & 4) != 0))
				.withProperty(POWERED, Boolean.valueOf((meta & 8) != 0));
	}
	
	public int getMetaFromState(IBlockState state) {
		int i = 0;
		i = i | ((EnumFacing) state.getValue(FACING)).getHorizontalIndex();

		if (((Boolean) state.getValue(POWERED)).booleanValue()) {
			i |= 8;
		}

		if (((Boolean) state.getValue(OPEN)).booleanValue()) {
			i |= 4;
		}

		return i;
	}
	
	protected BlockStateContainer createBlockState() {
		return new BlockStateContainer(this, new IProperty[] { FACING, OPEN, POWERED, IN_WALL });
	}
	
	@Override
	public boolean canBeConnectedTo(IBlockAccess world, BlockPos pos, EnumFacing facing) {
		Block connector = world.getBlockState(pos.offset(facing)).getBlock();
		return connector instanceof BlockFence || connector instanceof BlockWall;
	}
	
	private boolean canFenceGateConnectTo(IBlockAccess world, BlockPos pos, EnumFacing facing) {
		Block block = world.getBlockState(pos.offset(facing)).getBlock();
		return block.canBeConnectedTo(world, pos.offset(facing), facing.getOpposite());
	}

}

 

masonwood_fence_gate.json

{
	"variants": {
		"facing=south,in_wall=false,open=false": { "model": "more_ores:masonwood_fence_gate_closed", "uvlock": true },
        "facing=west,in_wall=false,open=false": { "model": "more_ores:masonwood_fence_gate_closed", "uvlock": true, "y": 90 },
        "facing=north,in_wall=false,open=false": { "model": "more_ores:masonwood_fence_gate_closed", "uvlock": true, "y": 180 },
        "facing=east,in_wall=false,open=false": { "model": "more_ores:masonwood_fence_gate_closed", "uvlock": true, "y": 270 },
        "facing=south,in_wall=false,open=true": { "model": "more_ores:masonwood_fence_gate_open", "uvlock": true },
        "facing=west,in_wall=false,open=true": { "model": "more_ores:masonwood_fence_gate_open", "uvlock": true, "y": 90 },
        "facing=north,in_wall=false,open=true": { "model": "more_ores:masonwood_fence_gate_open", "uvlock": true, "y": 180 },
        "facing=east,in_wall=false,open=true": { "model": "more_ores:masonwood_fence_gate_open", "uvlock": true, "y": 270 },
        "facing=south,in_wall=true,open=false": { "model": "more_ores:masonwood_wall_gate_closed", "uvlock": true },
        "facing=west,in_wall=true,open=false": { "model": "more_ores:masonwood_wall_gate_closed", "uvlock": true, "y": 90 },
        "facing=north,in_wall=true,open=false": { "model": "more_ores:masonwood_wall_gate_closed", "uvlock": true, "y": 180 },
        "facing=east,in_wall=true,open=false": { "model": "more_ores:masonwood_wall_gate_closed", "uvlock": true, "y": 270 },
        "facing=south,in_wall=true,open=true": { "model": "more_ores:masonwood_wall_gate_open", "uvlock": true },
        "facing=west,in_wall=true,open=true": { "model": "more_ores:masonwood_wall_gate_open", "uvlock": true, "y": 90 },
        "facing=north,in_wall=true,open=true": { "model": "more_ores:masonwood_wall_gate_open", "uvlock": true, "y": 180 },
        "facing=east,in_wall=true,open=true": { "model": "more_ores:masonwood_wall_gate_open", "uvlock": true, "y": 270 }
	}
}

 

Edited by Emerald_Galaxy
Missing Information
Posted
56 minutes ago, Emerald_Galaxy said:

So I Recently Started Modding, After Finally Being Able To Learn Java...

There is no need to capitalize every word.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • So I started an MC server with some friends. It worked perfectly last night, but this morning I get the error that my PlayerData is invalid. I tried deleting my player data along with my cobblemon player pokemon storage data (for the cobblemon mod). I am still having the issue. https://pastes.io/log-38182 is my latest log, though I am not great at deciphering it. Any help would be appreciated. I have already tried using Packet Fixer aswell. I really would prefer to not have to delete the world.  
    • Looks like an issue with one of the create addons - remove these one by one
    • I have no idea - maybe it is directly an issue with mohist
    • I made a custom pack, but i can't even load it, it just crashes at launcher, giving me Error 1. I looked at the log, and it just doesn't seem to tell me what the issue actually is. Here's the report.   Edit- Trying to get report, but copy paste being weird [22:59:59] [main/ERROR]:Error replacing mixin module source java.lang.ClassNotFoundException: cpw.mods.cl.JarModuleFinder$JarModuleReference at java.base/jdk.internal.loader.Loader.loadClass(Loader.java:571) ~[?:?] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526) ~[?:?] at cpw.mods.securejarhandler/net.minecraftforge.securemodules.SecureModuleClassLoader.loadClass(SecureModuleClassLoader.java:429) ~[securemodules-2.2.21.jar!/:?] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526) ~[?:?] at java.base/java.lang.Class.forName0(Native Method) ~[?:?] at java.base/java.lang.Class.forName(Class.java:421) ~[?:?] at java.base/java.lang.Class.forName(Class.java:412) ~[?:?] at LAYER SERVICE/[email protected]+1.20.1/io.github.steelwoolmc.mixintransmog.InstrumentationHack.inject(InstrumentationHack.java:46) ~[?:?] at LAYER SERVICE/[email protected]+1.20.1/io.github.steelwoolmc.mixintransmog.MixinTransformationService.<init>(MixinTransformationService.java:59) ~[?:?] at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62) [?:?] at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502) [?:?] at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486) [?:?] at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:789) [?:?] at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:729) [?:?] at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1403) [?:?] at SECURE-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.TransformationServicesHandler.discoverServices(TransformationServicesHandler.java:156) [modlauncher-10.2.4.jar!/:?] at SECURE-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.Launcher.run(Launcher.java:84) [modlauncher-10.2.4.jar!/:?] at SECURE-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.Launcher.main(Launcher.java:75) [modlauncher-10.2.4.jar!/:?] at SECURE-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.BootstrapEntry.main(BootstrapEntry.java:17) [modlauncher-10.2.4.jar!/:?] at [email protected]/net.minecraftforge.bootstrap.Bootstrap.moduleMain(Bootstrap.java:188) [bootstrap-2.1.8.jar!/:?] at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[?:?] at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[?:?] at net.minecraftforge.bootstrap.Bootstrap.bootstrapMain(Bootstrap.java:133) [bootstrap-2.1.8.jar:2.1.8] at net.minecraftforge.bootstrap.Bootstrap.start(Bootstrap.java:53) [bootstrap-2.1.8.jar:2.1.8] at net.minecraftforge.bootstrap.ForgeBootstrap.main(ForgeBootstrap.java:19) [bootstrap-2.1.8.jar:2.1.8] [22:59:59] [main/FATAL]:Encountered serious error loading transformation service, expect problems java.util.ServiceConfigurationError: cpw.mods.modlauncher.api.ITransformationService: Provider io.github.steelwoolmc.mixintransmog.MixinTransformationService could not be instantiated at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:586) ~[?:?] at SECURE-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.TransformationServicesHandler.discoverServices(TransformationServicesHandler.java:156) [modlauncher-10.2.4.jar!/:?] at SECURE-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.Launcher.run(Launcher.java:84) [modlauncher-10.2.4.jar!/:?] at SECURE-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.Launcher.main(Launcher.java:75) [modlauncher-10.2.4.jar!/:?] at SECURE-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.BootstrapEntry.main(BootstrapEntry.java:17) [modlauncher-10.2.4.jar!/:?] at [email protected]/net.minecraftforge.bootstrap.Bootstrap.moduleMain(Bootstrap.java:188) [bootstrap-2.1.8.jar!/:?] at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[?:?] at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[?:?] at net.minecraftforge.bootstrap.Bootstrap.bootstrapMain(Bootstrap.java:133) [bootstrap-2.1.8.jar:2.1.8] at net.minecraftforge.bootstrap.Bootstrap.start(Bootstrap.java:53) [bootstrap-2.1.8.jar:2.1.8] at net.minecraftforge.bootstrap.ForgeBootstrap.main(ForgeBootstrap.java:19) [bootstrap-2.1.8.jar:2.1.8] Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: cpw.mods.cl.JarModuleFinder$JarModuleReference at LAYER SERVICE/[email protected]+1.20.1/io.github.steelwoolmc.mixintransmog.MixinTransformationService.<init>(MixinTransformationService.java:62) ~[?:?] at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62) ~[?:?] at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502) ~[?:?] at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486) ~[?:?] at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:789) ~[?:?] ... 12 more Caused by: java.lang.ClassNotFoundException: cpw.mods.cl.JarModuleFinder$JarModuleReference at java.base/jdk.internal.loader.Loader.loadClass(Loader.java:571) ~[?:?] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526) ~[?:?] at cpw.mods.securejarhandler/net.minecraftforge.securemodules.SecureModuleClassLoader.loadClass(SecureModuleClassLoader.java:429) ~[securemodules-2.2.21.jar!/:?] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526) ~[?:?] at java.base/java.lang.Class.forName0(Native Method) ~[?:?] at java.base/java.lang.Class.forName(Class.java:421) ~[?:?] at java.base/java.lang.Class.forName(Class.java:412) ~[?:?] at LAYER SERVICE/[email protected]+1.20.1/io.github.steelwoolmc.mixintransmog.InstrumentationHack.inject(InstrumentationHack.java:46) ~[?:?] at LAYER SERVICE/[email protected]+1.20.1/io.github.steelwoolmc.mixintransmog.MixinTransformationService.<init>(MixinTransformationService.java:59) ~[?:?] at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62) ~[?:?] at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502) ~[?:?] at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486) ~[?:?] at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:789) ~[?:?] ... 12 more [22:59:59] [main/INFO]:SpongePowered MIXIN Subsystem Version=0.8.7 Source=jar:file:///C:/Users/mxz/curseforge/minecraft/Install/libraries/org/spongepowered/mixin/0.8.7/mixin-0.8.7.jar!/ Service=ModLauncher Env=CLIENT at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:813) ~[?:?] at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:729) ~[?:?] at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1403) ~[?:?]
    • here is a different world https://ibb.co/Q3VWj9gW and the server console https://ibb.co/dwQf0qrR
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.