Skip to content

Commit

Permalink
1.4.0-beta3 hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshieGemFinder committed Feb 18, 2024
1 parent 104dd92 commit 4c79be8
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -313,32 +313,38 @@ public ItemStack dispenseStack(IBlockSource source, ItemStack stack)
BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(ItemRegistry.BL_BUCKET, new IBehaviorDispenseItem() {
@Override
public ItemStack dispense(IBlockSource source, ItemStack stack) {

if (FluidUtil.getFluidContained(stack) != null) {
EnumFacing enumfacing = (EnumFacing)source.getBlockState().getValue(BlockDispenser.FACING);
World world = source.getWorld();
BlockPos fillPos = source.getBlockPos().offset(enumfacing);
IFluidHandler fluidHandler = FluidUtil.getFluidHandler(world, fillPos, enumfacing.getOpposite());
if(fluidHandler != null && !(fluidHandler instanceof BlockLiquidWrapper)) {
net.minecraftforge.fluids.FluidActionResult actionResult = FluidUtil.tryEmptyContainer(stack, fluidHandler, Fluid.BUCKET_VOLUME, null, true);
if(actionResult.isSuccess()) {
ItemStack drainedStack = actionResult.getResult();
//so we don't play the sound multiple times if this fails
source.getWorld().playEvent(1000, source.getBlockPos(), 0); //playDispenseSound
EnumFacing facing = (EnumFacing)source.getBlockState().getValue(BlockDispenser.FACING); // getWorldEventDataFrom
source.getWorld().playEvent(2000, source.getBlockPos(), facing.getFrontOffsetX() + 1 + (facing.getFrontOffsetZ() + 1) * 3); // spawnDispenseParticles
if(stack.getCount() == 1) {
return drainedStack;
}
else if (!drainedStack.isEmpty() && ((TileEntityDispenser)source.getBlockTileEntity()).addItemStack(drainedStack) < 0)
{
behaviourDefaultDispenseItem.dispense(source, drainedStack);
}

ItemStack stackCopy = stack.copy();
stackCopy.shrink(1);
return stackCopy;
}

EnumFacing enumfacing = (EnumFacing)source.getBlockState().getValue(BlockDispenser.FACING);
World world = source.getWorld();
BlockPos fillPos = source.getBlockPos().offset(enumfacing);
IFluidHandler fluidHandler = FluidUtil.getFluidHandler(world, fillPos, enumfacing.getOpposite());

if(fluidHandler != null && !(fluidHandler instanceof BlockLiquidWrapper)) {
net.minecraftforge.fluids.FluidActionResult actionResult;
if (FluidUtil.getFluidContained(stack) != null) {
actionResult = FluidUtil.tryEmptyContainer(stack, fluidHandler, Fluid.BUCKET_VOLUME, null, true);
} else {
actionResult = FluidUtil.tryFillContainer(stack, fluidHandler, Fluid.BUCKET_VOLUME, null, true);
}


if(actionResult.isSuccess()) {
ItemStack modifiedStack = actionResult.getResult();
//so we don't play the sound multiple times if this fails
source.getWorld().playEvent(1000, source.getBlockPos(), 0); //playDispenseSound
EnumFacing facing = (EnumFacing)source.getBlockState().getValue(BlockDispenser.FACING); // getWorldEventDataFrom
source.getWorld().playEvent(2000, source.getBlockPos(), facing.getFrontOffsetX() + 1 + (facing.getFrontOffsetZ() + 1) * 3); // spawnDispenseParticles
if(stack.getCount() == 1) {
return modifiedStack;
}
else if (!modifiedStack.isEmpty() && ((TileEntityDispenser)source.getBlockTileEntity()).addItemStack(modifiedStack) < 0)
{
behaviourDefaultDispenseItem.dispense(source, modifiedStack);
}

ItemStack stackCopy = stack.copy();
stackCopy.shrink(1);
return stackCopy;
}
}

Expand Down Expand Up @@ -653,6 +659,7 @@ public ItemStack dispenseStack(IBlockSource source, ItemStack stack)
item.getItem().setStackDisplayName(stack.getDisplayName());
}


return stack;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class BlockScabystPistonMoving extends BlockPistonMoving implements IModelInterface {

Expand Down Expand Up @@ -75,6 +77,7 @@ public void onBlockDestroyedByPlayer(World worldIn, BlockPos pos, IBlockState st
}

@Override
@SideOnly(Side.CLIENT)
public void registerModels() { // built-in block model
ModelLoader.setCustomStateMapper(this, new IStateMapper() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public byte[] transform(String name, String transformedName, byte[] classBytes)
classReader.accept(classNode, 0);
final boolean successful = this.transformClass(classNode, name, transformedName, classBytes);

System.out.println("Transform successful? " + String.valueOf(successful));
// System.out.println("Transform successful? " + String.valueOf(successful));
if(!successful) {
return classBytes;
}
Expand Down

0 comments on commit 4c79be8

Please sign in to comment.