From fc048d4e76bf380655865c32b381c8a3ad4d8eb3 Mon Sep 17 00:00:00 2001 From: grimmauld Date: Thu, 3 Sep 2020 12:41:08 +0200 Subject: [PATCH] Access transform go poof --- .../dispenser/DispenserMovementBehaviour.java | 18 +++++++++++++++++- .../resources/META-INF/accesstransformer.cfg | 5 +---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/DispenserMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/DispenserMovementBehaviour.java index e12cd1df2..c69cff722 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/DispenserMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/DispenserMovementBehaviour.java @@ -2,6 +2,8 @@ package com.simibubi.create.content.contraptions.components.actors.dispenser; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.foundation.utility.VecHelper; +import mcp.MethodsReturnNonnullByDefault; +import net.minecraft.block.Block; import net.minecraft.block.Blocks; import net.minecraft.block.DispenserBlock; import net.minecraft.dispenser.DefaultDispenseItemBehavior; @@ -12,10 +14,12 @@ import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; +import javax.annotation.ParametersAreNonnullByDefault; import java.util.HashMap; public class DispenserMovementBehaviour extends DropperMovementBehaviour { private static final HashMap MOVED_DISPENSE_ITEM_BEHAVIOURS = new HashMap<>(); + private static final DispenserLookup BEHAVIOUR_LOOKUP = new DispenserLookup(); public static void gatherMovedDispenseItemBehaviours() { IMovedDispenseItemBehaviour.init(); @@ -47,7 +51,7 @@ public class DispenserMovementBehaviour extends DropperMovementBehaviour { facingVec.normalize(); Direction clostestFacing = Direction.getFacingFromVector(facingVec.x, facingVec.y, facingVec.z); ContraptionBlockSource blockSource = new ContraptionBlockSource(context, pos, clostestFacing); - IDispenseItemBehavior idispenseitembehavior = ((DispenserBlock) Blocks.DISPENSER).getBehavior(itemstack); + IDispenseItemBehavior idispenseitembehavior = BEHAVIOUR_LOOKUP.getBehavior(itemstack); if (idispenseitembehavior.getClass() != DefaultDispenseItemBehavior.class) { // There is a dispense item behaviour registered for the vanilla dispenser idispenseitembehavior.dispense(blockSource, itemstack); return; @@ -59,4 +63,16 @@ public class DispenserMovementBehaviour extends DropperMovementBehaviour { defaultBehaviour.dispense(itemstack, context, pos); // the default: launch the item } } + + @ParametersAreNonnullByDefault + @MethodsReturnNonnullByDefault + private static class DispenserLookup extends DispenserBlock { + protected DispenserLookup() { + super(Block.Properties.from(Blocks.DISPENSER)); + } + + public IDispenseItemBehavior getBehavior(ItemStack itemStack) { + return super.getBehavior(itemStack); + } + } } diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index e5bea6c04..5af4e7e17 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -1,7 +1,4 @@ public net.minecraft.network.play.ServerPlayNetHandler field_147365_f # floatingTickCount # CubeParticle -protected net.minecraft.client.particle.Particle field_228343_B_ # collidedY - -# Dispenser movement behaviour default -public net.minecraft.block.DispenserBlock func_149940_a(Lnet/minecraft/item/ItemStack;)Lnet/minecraft/dispenser/IDispenseItemBehavior; # getBehavior \ No newline at end of file +protected net.minecraft.client.particle.Particle field_228343_B_ # collidedY \ No newline at end of file