Jump to content

Recommended Posts

Posted

I am making an Itemduct block which will connect to every Itemduct on its sides.

Though for some reason only the default model is visible (is the center part of the Itemduct)

 

blockstates/Itemduct.json:

{
    "forge_marker": 1,
    "defaults": {
    	"model": "se:block/iron_itemduct"
    },
	"variants": {
		"up": {
			"true": {
				"submodel": "se:block/iron_itemduct_side",
				"x": 90
			},
			"false": { }
		},
		"down": {
			"true": {
				"submodel": "se:block/iron_itemduct_side",
				"x": 180
			},
			"false": { }
		},
		"east": {
			"true": {
				"submodel": "se:block/iron_itemduct_side",
				"y": 90
			},
			"false": { }
		},
		"south": {
			"true": {
				"submodel": "se:block/iron_itemduct_side",
				"y": 180
			},
			"false": { }
		},
		"west": {
			"true": {
				"submodel": "se:block/iron_itemduct_side",
				"y": 270
			},
			"false": { }
		},
		"north": {
			"true": {
				"submodel": "se:block/iron_itemduct_side"
			},
			"false": { }
		}
	}
}

 

models/block/itemduct.json: <- This is the parent model of models/block/iron_itemduct

{
	"__comment": "Designed by Marca with Cubik Studio - https://cubik.studio",
	"textures": {
		"particle": "#center"
	},
    "display": {
        "gui": {
            "rotation": [ 30, 45, 0 ],
            "translation": [ 0, -1.5, 0 ],
            "scale": [ 0.625, 0.625, 0.625 ]
        },
        "ground": {
            "rotation": [ 0, 0, 0 ],
            "translation": [ 0, 3, 0 ],
            "scale": [ 0.25, 0.25, 0.25 ]
        },
        "fixed": {
            "rotation": [ 0, 180, 0 ],
            "translation": [ 0, 0, 0 ],
            "scale": [ 1, 1, 1 ]
        },
        "firstperson_righthand": {
            "rotation": [ 0, 315, 0 ],
            "translation": [ 0, 2.5, 0 ],
            "scale": [ 0.4, 0.4, 0.4 ]
        },
        "thirdperson_righthand": {
            "rotation": [ 0, 315, 0 ],
            "translation": [ 0, 0.5, 1 ],
            "scale": [ 0.375, 0.375, 0.375 ]
        }
    },
	"elements": [ 	 
		{
			"from": [ 6, 6, 6 ],
			"to": [ 10, 10, 10 ],
			"faces": {
				"down": { "uv": [ 6, 6, 10, 10 ], "texture": "#center" },
				"up": { "uv": [ 6, 6, 10, 10 ], "texture": "#center" },
				"north": { "uv": [ 6, 6, 10, 10 ], "texture": "#center" },
				"south": { "uv": [ 6, 6, 10, 10 ], "texture": "#center" },
				"west": { "uv": [ 6, 6, 10, 10 ], "texture": "#center" },
				"east": { "uv": [ 6, 6, 10, 10 ], "texture": "#center" }
			}
		}
	]
}

 

models/block/itemduct_side: <- This is the parent model of models/block/iron_itemduct_side

{
	"__comment": "Designed by Marca with Cubik Studio - https://cubik.studio",
	"elements": [
		{
			"from": [ 6, 6, 10 ],
			"to": [10, 10, 16 ],
			"faces": {
				"down": { "uv": [ 10, 6, 16, 10 ], "texture": "#side" },
				"up": { "uv": [ 10, 6, 16, 10 ], "texture": "#side" },
				"north": { "uv": [ 0, 6, 6, 10 ], "texture": "#side", "cullface": "north" },
				"south": { "uv": [ 10, 6, 16, 10 ], "texture": "#side" },
				"west": { "uv": [ 6, 6, 10, 10 ], "texture": "#side" },
				"east": { "uv": [ 6, 6, 10, 10 ], "texture": "#side" }
			}
		}
	]
}

 

ItemductBlock:

public class ItemductBlock extends SurvivalEvolvedWaterloggedBlock
{

	public static final BooleanProperty UP = BooleanProperty.create("up");
	public static final BooleanProperty DOWN = BooleanProperty.create("down");
	public static final BooleanProperty EAST = BooleanProperty.create("east");
	public static final BooleanProperty SOUTH = BooleanProperty.create("south");
	public static final BooleanProperty WEST = BooleanProperty.create("west");
	public static final BooleanProperty NORTH = BooleanProperty.create("north");

	public final ImmutableMap<BlockState, VoxelShape> SHAPES;

	public ItemductBlock (Properties properties)
	{
		super(properties);
		setDefaultState(getStateContainer().getBaseState().with(UP, false).with(DOWN, false).with(NORTH, false).with(EAST, false).with(SOUTH, false)
				.with(WEST, false));
		SHAPES = generateShapes(getStateContainer().getValidStates());
	}
	
	private ImmutableMap<BlockState, VoxelShape> generateShapes (ImmutableList<BlockState> states)
	{
		final VoxelShape ITEMDUCT_CENTER = Block.makeCuboidShape(6.0, 6.0, 6.0, 10.0, 10.0, 10.0);
		final VoxelShape ITEMDUCT_SIDE = Block.makeCuboidShape(10.0, 6.0, 6.0, 16.0, 10.0, 10.0);
		
		ImmutableMap.Builder<BlockState, VoxelShape> builder = new ImmutableMap.Builder<>();
		for (BlockState state : states)
		{
			boolean up = state.get(UP);
			boolean down = state.get(DOWN);
			boolean east = state.get(EAST);
			boolean south = state.get(SOUTH);
			boolean west = state.get(WEST);
			boolean north = state.get(NORTH);
			
			List<VoxelShape> shapes = new ArrayList<>();
			shapes.add(ITEMDUCT_CENTER);

			if (up) shapes.add(VoxelShapeHelper.rotate(ITEMDUCT_SIDE, Direction.UP));
			if (down) shapes.add(VoxelShapeHelper.rotate(ITEMDUCT_SIDE, Direction.DOWN));
			if (east) shapes.add(VoxelShapeHelper.rotate(ITEMDUCT_SIDE, Direction.EAST));
			if (south) shapes.add(VoxelShapeHelper.rotate(ITEMDUCT_SIDE, Direction.SOUTH));
			if (west) shapes.add(VoxelShapeHelper.rotate(ITEMDUCT_SIDE, Direction.WEST));
			if (north) shapes.add(VoxelShapeHelper.rotate(ITEMDUCT_SIDE, Direction.NORTH));
			
			builder.put(state, VoxelShapeHelper.combineAll(shapes));
		}
		return builder.build();
	}

	@Override
	public VoxelShape getShape (BlockState state, IBlockReader reader, BlockPos pos, ISelectionContext context)
	{
		return SHAPES.get(state);
	}

	@Override
	public VoxelShape getCollisionShape (BlockState state, IBlockReader reader, BlockPos pos, ISelectionContext context)
	{
		return SHAPES.get(state);
	}

	@Override
	public BlockState updatePostPlacement (BlockState state, Direction direction, BlockState newState, IWorld world,
			BlockPos pos, BlockPos newPos)
	{
		boolean up = world.getBlockState(pos.up()).getBlock() == this;
		boolean down = world.getBlockState(pos.down()).getBlock() == this;
		boolean east = world.getBlockState(pos.east()).getBlock() == this;
		boolean south = world.getBlockState(pos.south()).getBlock() == this;
		boolean west = world.getBlockState(pos.west()).getBlock() == this;
		boolean north = world.getBlockState(pos.north()).getBlock() == this;
		
		return state.with(UP, up).with(DOWN, down).with(EAST, east).with(SOUTH, south).with(WEST, west).with(NORTH, north);
	}
	
	@Override
	protected void fillStateContainer (Builder<Block, BlockState> builder)
	{
		super.fillStateContainer(builder);
		builder.add(UP);
		builder.add(DOWN);
		builder.add(EAST);
		builder.add(SOUTH);
		builder.add(WEST);
		builder.add(NORTH);
	}

}
Posted (edited)

So apparently i was able to use the vanilla BlockStates and so the fix was simply put:
 

{
	"multipart": [
		{
			"apply": { "model": "se:block/iron_itemduct" }
		},
		{
			"when": { "up": "true" },
			"apply": { "model": "se:block/iron_itemduct_side", "x": 90 }
		}
	]
}

 

Though this is a vanilla fix, not a Forge fix

Edited by Marca

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

    • i dont have any crash reports i only have the latest log https://mclo.gs/DONwR2g
    • Maybe it is an issue with one of the Create addons Create_The_Kitchen_Must_Grow is the last mentioned mod
    • I cannot find any information on why this is specifically happening in any of the logs and i'm getting annoyed. it manifests primarily as lag when breaking and placing blocks, or picking up items. Items will be picked up than disappear, only to appear in my inventory many seconds later, blocks will not place for over 30 seconds at a time. observable shows 100459 μs/t on minecraft:player spark profile doesnt seem to show anything strange as far as i can tell though except for that about 20% of the usage is something called crusty_chunks and another 20% is distant horizons, even when i have distant rendering disabled. I've attached the latest.log, spark profile and observable exports.
    • [16:07:39] [main/INFO]:Mixins added to allowed list: [main.ClientPacketListenerMixin] [16:07:39] [main/INFO]:Class dev.uncandango.alltheleaks.leaks.client.mods.ae2wtlib.UntrackedIssue002 will NOT be loaded as mod ae2wtlib is not present [16:07:39] [main/INFO]:Class dev.uncandango.alltheleaks.leaks.client.mods.ae2wtlib.UntrackedIssue001 will NOT be loaded as mod ae2wtlib is not present [16:07:39] [main/INFO]:Class dev.uncandango.alltheleaks.fix.common.mods.modernfix.CancelRLMixin will be loaded as it matches versions: 5.20.2+mc1.20.1 in [5.0.0,) [16:07:39] [main/INFO]:Mixins added to cancel list: [org.embeddedt.modernfix.common.mixin.perf.deduplicate_location.MixinResourceLocation] [16:07:39] [main/INFO]:Skipping feature ResourceLocation Deduplication from mod minecraft as it's feature flag is not activated! [16:07:39] [main/INFO]:Skipping feature Ingredient Deduplication from mod minecraft as it's feature flag is not activated! [16:07:39] [main/INFO]:Skipping feature Prevent Search Ignored Items from mod jei as it's feature flag is not activated! [16:07:39] [main/WARN]:Error loading class: com/jozufozu/flywheel/util/WorldAttached (java.lang.ClassNotFoundException: com.jozufozu.flywheel.util.WorldAttached) [16:07:39] [main/WARN]:@Mixin target com.jozufozu.flywheel.util.WorldAttached was not found alltheleaks.mixins.json:main.WorldAttachedMixin from mod alltheleaks [16:07:39] [main/INFO]:Loaded config for: betterfpsdist.json [16:07:39] [main/INFO]:Loaded config for: structureessentials.json [16:07:39] [main/WARN]:Error loading class: dev/tr7zw/skinlayers/render/CustomizableModelPart (java.lang.ClassNotFoundException: dev.tr7zw.skinlayers.render.CustomizableModelPart) [16:07:39] [main/INFO]:Loading mixin: de.johni0702.minecraft.bobby.mixin.BackgroundRendererMixin [16:07:39] [main/INFO]:Loading mixin: de.johni0702.minecraft.bobby.mixin.BiomeAccessAccessor [16:07:39] [main/INFO]:Loading mixin: de.johni0702.minecraft.bobby.mixin.ChunkLightProviderMixin [16:07:39] [main/INFO]:Loading mixin: de.johni0702.minecraft.bobby.mixin.ChunkLightProviderMixin [16:07:39] [main/INFO]:Loading mixin: de.johni0702.minecraft.bobby.mixin.ChunkLightProviderMixin [16:07:39] [main/INFO]:Loading mixin: de.johni0702.minecraft.bobby.mixin.ClientChunkManagerMixin [16:07:39] [main/INFO]:Loading mixin: de.johni0702.minecraft.bobby.mixin.ClientSettingsC2SPacketMixin [16:07:39] [main/INFO]:Loading mixin: de.johni0702.minecraft.bobby.mixin.ClientWorldAccessor [16:07:39] [main/INFO]:Loading mixin: de.johni0702.minecraft.bobby.mixin.GameOptionsMixin [16:07:39] [main/INFO]:Loading mixin: de.johni0702.minecraft.bobby.mixin.GameRendererMixin [16:07:39] [main/INFO]:Loading mixin: de.johni0702.minecraft.bobby.mixin.IntegratedServerMixin [16:07:39] [main/INFO]:Loading mixin: de.johni0702.minecraft.bobby.mixin.LightingProviderMixin [16:07:39] [main/INFO]:Loading mixin: de.johni0702.minecraft.bobby.mixin.MinecraftClientMixin [16:07:39] [main/INFO]:Loading mixin: de.johni0702.minecraft.bobby.mixin.SimpleOptionAccessor [16:07:39] [main/INFO]:Loading mixin: de.johni0702.minecraft.bobby.mixin.ValidatingIntSliderCallbacksAccessor [16:07:39] [main/INFO]:Loading mixin: de.johni0702.minecraft.bobby.mixin.sodium.SodiumChunkManagerMixin [16:07:39] [main/INFO]:Loading mixin: de.johni0702.minecraft.bobby.mixin.sodium.SodiumClientPlayNetworkHandlerMixin [16:07:39] [main/INFO]:Loading mixin: de.johni0702.minecraft.bobby.mixin.sodium.SodiumGameOptionPagesMixin [16:07:40] [main/INFO]:Replaced 1 calls to Enchantment#getMaxLevel() in net/minecraft/world/entity/npc/VillagerTrades$EnchantBookForEmeralds [16:07:40] [main/INFO]:Replaced 1 calls to Enchantment#isTreasureOnly() in net/minecraft/world/entity/npc/VillagerTrades$EnchantBookForEmeralds [16:07:40] [main/INFO]:Replaced 1 calls to Enchantment#isTradeable() in net/minecraft/world/entity/npc/VillagerTrades$EnchantBookForEmeralds [16:07:40] [main/INFO]:Loaded config for: recipeessentials.json [16:07:40] [main/INFO]:Patching FishingHook#catchingFish
  • Topics

×
×
  • Create New...

Important Information

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