mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-27 23:45:44 +00:00
Regenerate patches with relative headers. This should lower conflicts in future PRs.
Convert Forge to use Official mappings. Mojang released their obfuscation mappings but we have not used them up until now due to wanting to get their license to be more explicitly permissive. It is clear that their intent is to allow us to use their names for developing mods like this. See the full wording, and our interpretation here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
This commit is contained in:
1 parent
802298d99d
commit
a95b968c13
832 files changed
+4464
-4373
No files matched your search
@@ -51,7 +51,7 @@ public class DispenseFluidContainer extends DefaultDispenseItemBehavior
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack dispenseStack(@Nonnull IBlockSource source, @Nonnull ItemStack stack)
|
||||
public ItemStack execute(@Nonnull IBlockSource source, @Nonnull ItemStack stack)
|
||||
{
|
||||
if (FluidUtil.getFluidContained(stack).isPresent())
|
||||
{
|
||||
@@ -69,23 +69,23 @@ public class DispenseFluidContainer extends DefaultDispenseItemBehavior
|
||||
@Nonnull
|
||||
private ItemStack fillContainer(@Nonnull IBlockSource source, @Nonnull ItemStack stack)
|
||||
{
|
||||
World world = source.getWorld();
|
||||
Direction dispenserFacing = source.getBlockState().get(DispenserBlock.FACING);
|
||||
BlockPos blockpos = source.getBlockPos().offset(dispenserFacing);
|
||||
World world = source.getLevel();
|
||||
Direction dispenserFacing = source.getBlockState().getValue(DispenserBlock.FACING);
|
||||
BlockPos blockpos = source.getPos().relative(dispenserFacing);
|
||||
|
||||
FluidActionResult actionResult = FluidUtil.tryPickUpFluid(stack, null, world, blockpos, dispenserFacing.getOpposite());
|
||||
ItemStack resultStack = actionResult.getResult();
|
||||
|
||||
if (!actionResult.isSuccess() || resultStack.isEmpty())
|
||||
{
|
||||
return super.dispenseStack(source, stack);
|
||||
return super.execute(source, stack);
|
||||
}
|
||||
|
||||
if (stack.getCount() == 1)
|
||||
{
|
||||
return resultStack;
|
||||
}
|
||||
else if (((DispenserTileEntity)source.getBlockTileEntity()).addItemStack(resultStack) < 0)
|
||||
else if (((DispenserTileEntity)source.getEntity()).addItem(resultStack) < 0)
|
||||
{
|
||||
this.dispenseBehavior.dispense(source, resultStack);
|
||||
}
|
||||
@@ -106,13 +106,13 @@ public class DispenseFluidContainer extends DefaultDispenseItemBehavior
|
||||
IFluidHandlerItem fluidHandler = FluidUtil.getFluidHandler(singleStack).orElse(null);
|
||||
if (fluidHandler == null)
|
||||
{
|
||||
return super.dispenseStack(source, stack);
|
||||
return super.execute(source, stack);
|
||||
}
|
||||
|
||||
FluidStack fluidStack = fluidHandler.drain(FluidAttributes.BUCKET_VOLUME, IFluidHandler.FluidAction.EXECUTE);
|
||||
Direction dispenserFacing = source.getBlockState().get(DispenserBlock.FACING);
|
||||
BlockPos blockpos = source.getBlockPos().offset(dispenserFacing);
|
||||
FluidActionResult result = FluidUtil.tryPlaceFluid(null, source.getWorld(), Hand.MAIN_HAND, blockpos, stack, fluidStack);
|
||||
Direction dispenserFacing = source.getBlockState().getValue(DispenserBlock.FACING);
|
||||
BlockPos blockpos = source.getPos().relative(dispenserFacing);
|
||||
FluidActionResult result = FluidUtil.tryPlaceFluid(null, source.getLevel(), Hand.MAIN_HAND, blockpos, stack, fluidStack);
|
||||
|
||||
if (result.isSuccess())
|
||||
{
|
||||
@@ -122,7 +122,7 @@ public class DispenseFluidContainer extends DefaultDispenseItemBehavior
|
||||
{
|
||||
return drainedStack;
|
||||
}
|
||||
else if (!drainedStack.isEmpty() && ((DispenserTileEntity)source.getBlockTileEntity()).addItemStack(drainedStack) < 0)
|
||||
else if (!drainedStack.isEmpty() && ((DispenserTileEntity)source.getEntity()).addItem(drainedStack) < 0)
|
||||
{
|
||||
this.dispenseBehavior.dispense(source, drainedStack);
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ public class FluidAttributes
|
||||
|
||||
protected FluidAttributes(Builder builder, Fluid fluid)
|
||||
{
|
||||
this.translationKey = builder.translationKey != null ? builder.translationKey : Util.makeTranslationKey("fluid", fluid.getRegistryName());
|
||||
this.translationKey = builder.translationKey != null ? builder.translationKey : Util.makeDescriptionId("fluid", fluid.getRegistryName());
|
||||
this.stillTexture = builder.stillTexture;
|
||||
this.flowingTexture = builder.flowingTexture;
|
||||
this.overlayTexture = builder.overlayTexture;
|
||||
@@ -149,17 +149,17 @@ public class FluidAttributes
|
||||
|
||||
public ItemStack getBucket(FluidStack stack)
|
||||
{
|
||||
return new ItemStack(stack.getFluid().getFilledBucket());
|
||||
return new ItemStack(stack.getFluid().getBucket());
|
||||
}
|
||||
|
||||
public BlockState getBlock(IBlockDisplayReader reader, BlockPos pos, FluidState state)
|
||||
{
|
||||
return state.getBlockState();
|
||||
return state.createLegacyBlock();
|
||||
}
|
||||
|
||||
public FluidState getStateForPlacement(IBlockDisplayReader reader, BlockPos pos, FluidStack state)
|
||||
{
|
||||
return state.getFluid().getDefaultState();
|
||||
return state.getFluid().defaultFluidState();
|
||||
}
|
||||
|
||||
public final boolean canBePlacedInWorld(IBlockDisplayReader reader, BlockPos pos, FluidState state)
|
||||
@@ -206,11 +206,11 @@ public class FluidAttributes
|
||||
*/
|
||||
public void vaporize(@Nullable PlayerEntity player, World worldIn, BlockPos pos, FluidStack fluidStack)
|
||||
{
|
||||
worldIn.playSound(player, pos, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (worldIn.rand.nextFloat() - worldIn.rand.nextFloat()) * 0.8F);
|
||||
worldIn.playSound(player, pos, SoundEvents.FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (worldIn.random.nextFloat() - worldIn.random.nextFloat()) * 0.8F);
|
||||
|
||||
for (int l = 0; l < 8; ++l)
|
||||
{
|
||||
worldIn.addOptionalParticle(ParticleTypes.LARGE_SMOKE, (double) pos.getX() + Math.random(), (double) pos.getY() + Math.random(), (double) pos.getZ() + Math.random(), 0.0D, 0.0D, 0.0D);
|
||||
worldIn.addAlwaysVisibleParticle(ParticleTypes.LARGE_SMOKE, (double) pos.getX() + Math.random(), (double) pos.getY() + Math.random(), (double) pos.getZ() + Math.random(), 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -443,7 +443,7 @@ public class FluidAttributes
|
||||
@Override
|
||||
public int getColor(IBlockDisplayReader world, BlockPos pos)
|
||||
{
|
||||
return BiomeColors.getWaterColor(world, pos) | 0xFF000000;
|
||||
return BiomeColors.getAverageWaterColor(world, pos) | 0xFF000000;
|
||||
}
|
||||
|
||||
public static Builder builder(ResourceLocation stillTexture, ResourceLocation flowingTexture) {
|
||||
|
||||
@@ -151,14 +151,14 @@ public class FluidStack
|
||||
{
|
||||
buf.writeRegistryId(getFluid());
|
||||
buf.writeVarInt(getAmount());
|
||||
buf.writeCompoundTag(tag);
|
||||
buf.writeNbt(tag);
|
||||
}
|
||||
|
||||
public static FluidStack readFromPacket(PacketBuffer buf)
|
||||
{
|
||||
Fluid fluid = buf.readRegistryId();
|
||||
int amount = buf.readVarInt();
|
||||
CompoundNBT tag = buf.readCompoundTag();
|
||||
CompoundNBT tag = buf.readNbt();
|
||||
if (fluid == Fluids.EMPTY) return EMPTY;
|
||||
return new FluidStack(fluid, amount, tag);
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ public class FluidUtil
|
||||
Preconditions.checkNotNull(hand);
|
||||
Preconditions.checkNotNull(handler);
|
||||
|
||||
ItemStack heldItem = player.getHeldItem(hand);
|
||||
ItemStack heldItem = player.getItemInHand(hand);
|
||||
if (!heldItem.isEmpty())
|
||||
{
|
||||
return player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
|
||||
@@ -111,7 +111,7 @@ public class FluidUtil
|
||||
|
||||
if (fluidActionResult.isSuccess())
|
||||
{
|
||||
player.setHeldItem(hand, fluidActionResult.getResult());
|
||||
player.setItemInHand(hand, fluidActionResult.getResult());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -148,7 +148,7 @@ public class FluidUtil
|
||||
if (player != null)
|
||||
{
|
||||
SoundEvent soundevent = simulatedTransfer.getFluid().getAttributes().getFillSound(simulatedTransfer);
|
||||
player.world.playSound(null, player.getPosX(), player.getPosY() + 0.5, player.getPosZ(), soundevent, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
player.level.playSound(null, player.getX(), player.getY() + 0.5, player.getZ(), soundevent, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -192,7 +192,7 @@ public class FluidUtil
|
||||
if (doDrain && player != null)
|
||||
{
|
||||
SoundEvent soundevent = transfer.getFluid().getAttributes().getEmptySound(transfer);
|
||||
player.world.playSound(null, player.getPosX(), player.getPosY() + 0.5, player.getPosZ(), soundevent, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
player.level.playSound(null, player.getX(), player.getY() + 0.5, player.getZ(), soundevent, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
ItemStack resultContainer = containerFluidHandler.getContainer();
|
||||
@@ -226,7 +226,7 @@ public class FluidUtil
|
||||
return FluidActionResult.FAILURE;
|
||||
}
|
||||
|
||||
if (player != null && player.abilities.isCreativeMode)
|
||||
if (player != null && player.abilities.instabuild)
|
||||
{
|
||||
FluidActionResult filledReal = tryFillContainer(container, fluidSource, maxAmount, player, doFill);
|
||||
if (filledReal.isSuccess())
|
||||
@@ -294,7 +294,7 @@ public class FluidUtil
|
||||
return FluidActionResult.FAILURE;
|
||||
}
|
||||
|
||||
if (player != null && player.abilities.isCreativeMode)
|
||||
if (player != null && player.abilities.instabuild)
|
||||
{
|
||||
FluidActionResult emptiedReal = tryEmptyContainer(container, fluidDestination, maxAmount, player, doDrain);
|
||||
if (emptiedReal.isSuccess())
|
||||
@@ -458,7 +458,7 @@ public class FluidUtil
|
||||
|
||||
if (block.hasTileEntity(state))
|
||||
{
|
||||
TileEntity tileEntity = world.getTileEntity(blockPos);
|
||||
TileEntity tileEntity = world.getBlockEntity(blockPos);
|
||||
if (tileEntity != null)
|
||||
{
|
||||
return tileEntity.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side);
|
||||
@@ -566,20 +566,20 @@ public class FluidUtil
|
||||
return false;
|
||||
}
|
||||
|
||||
BlockItemUseContext context = new BlockItemUseContext(world, player, hand, player == null ? ItemStack.EMPTY : player.getHeldItem(hand), new BlockRayTraceResult(Vector3d.ZERO, Direction.UP, pos, false));
|
||||
BlockItemUseContext context = new BlockItemUseContext(world, player, hand, player == null ? ItemStack.EMPTY : player.getItemInHand(hand), new BlockRayTraceResult(Vector3d.ZERO, Direction.UP, pos, false));
|
||||
|
||||
// check that we can place the fluid at the destination
|
||||
BlockState destBlockState = world.getBlockState(pos);
|
||||
Material destMaterial = destBlockState.getMaterial();
|
||||
boolean isDestNonSolid = !destMaterial.isSolid();
|
||||
boolean isDestReplaceable = destBlockState.isReplaceable(context);
|
||||
boolean canDestContainFluid = destBlockState.getBlock() instanceof ILiquidContainer && ((ILiquidContainer) destBlockState.getBlock()).canContainFluid(world, pos, destBlockState, fluid);
|
||||
if (!world.isAirBlock(pos) && !isDestNonSolid && !isDestReplaceable && !canDestContainFluid)
|
||||
boolean isDestReplaceable = destBlockState.canBeReplaced(context);
|
||||
boolean canDestContainFluid = destBlockState.getBlock() instanceof ILiquidContainer && ((ILiquidContainer) destBlockState.getBlock()).canPlaceLiquid(world, pos, destBlockState, fluid);
|
||||
if (!world.isEmptyBlock(pos) && !isDestNonSolid && !isDestReplaceable && !canDestContainFluid)
|
||||
{
|
||||
return false; // Non-air, solid, unreplacable block. We can't put fluid here.
|
||||
}
|
||||
|
||||
if (world.getDimensionType().isUltrawarm() && fluid.getAttributes().doesVaporize(world, pos, resource))
|
||||
if (world.dimensionType().ultraWarm() && fluid.getAttributes().doesVaporize(world, pos, resource))
|
||||
{
|
||||
FluidStack result = fluidSource.drain(resource, IFluidHandler.FluidAction.EXECUTE);
|
||||
if (!result.isEmpty())
|
||||
@@ -619,7 +619,7 @@ public class FluidUtil
|
||||
*/
|
||||
private static IFluidHandler getFluidBlockHandler(Fluid fluid, World world, BlockPos pos)
|
||||
{
|
||||
BlockState state = fluid.getAttributes().getBlock(world, pos, fluid.getDefaultState());
|
||||
BlockState state = fluid.getAttributes().getBlock(world, pos, fluid.defaultFluidState());
|
||||
return new BlockWrapper(state, world, pos);
|
||||
}
|
||||
|
||||
@@ -634,7 +634,7 @@ public class FluidUtil
|
||||
*/
|
||||
public static void destroyBlockOnFluidPlacement(World world, BlockPos pos)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
if (!world.isClientSide)
|
||||
{
|
||||
BlockState destBlockState = world.getBlockState(pos);
|
||||
Material destMaterial = destBlockState.getMaterial();
|
||||
|
||||
@@ -70,28 +70,28 @@ public abstract class ForgeFlowingFluid extends FlowingFluid
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fluid getFlowingFluid()
|
||||
public Fluid getFlowing()
|
||||
{
|
||||
return flowing.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fluid getStillFluid()
|
||||
public Fluid getSource()
|
||||
{
|
||||
return still.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canSourcesMultiply()
|
||||
protected boolean canConvertToSource()
|
||||
{
|
||||
return canMultiply;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void beforeReplacingBlock(IWorld worldIn, BlockPos pos, BlockState state)
|
||||
protected void beforeDestroyingBlock(IWorld worldIn, BlockPos pos, BlockState state)
|
||||
{
|
||||
TileEntity tileentity = state.getBlock().hasTileEntity(state) ? worldIn.getTileEntity(pos) : null;
|
||||
Block.spawnDrops(state, worldIn, pos, tileentity);
|
||||
TileEntity tileentity = state.getBlock().hasTileEntity(state) ? worldIn.getBlockEntity(pos) : null;
|
||||
Block.dropResources(state, worldIn, pos, tileentity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -101,26 +101,26 @@ public abstract class ForgeFlowingFluid extends FlowingFluid
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLevelDecreasePerBlock(IWorldReader worldIn)
|
||||
protected int getDropOff(IWorldReader worldIn)
|
||||
{
|
||||
return levelDecreasePerBlock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getFilledBucket()
|
||||
public Item getBucket()
|
||||
{
|
||||
return bucket != null ? bucket.get() : Items.AIR;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canDisplace(FluidState state, IBlockReader world, BlockPos pos, Fluid fluidIn, Direction direction)
|
||||
protected boolean canBeReplacedWith(FluidState state, IBlockReader world, BlockPos pos, Fluid fluidIn, Direction direction)
|
||||
{
|
||||
// Based on the water implementation, may need to be overriden for mod fluids that shouldn't behave like water.
|
||||
return direction == Direction.DOWN && !isEquivalentTo(fluidIn);
|
||||
return direction == Direction.DOWN && !isSame(fluidIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTickRate(IWorldReader world)
|
||||
public int getTickDelay(IWorldReader world)
|
||||
{
|
||||
return tickRate;
|
||||
}
|
||||
@@ -132,15 +132,15 @@ public abstract class ForgeFlowingFluid extends FlowingFluid
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockState getBlockState(FluidState state)
|
||||
protected BlockState createLegacyBlock(FluidState state)
|
||||
{
|
||||
if (block != null)
|
||||
return block.get().getDefaultState().with(FlowingFluidBlock.LEVEL, getLevelFromState(state));
|
||||
return Blocks.AIR.getDefaultState();
|
||||
return block.get().defaultBlockState().setValue(FlowingFluidBlock.LEVEL, getLegacyLevel(state));
|
||||
return Blocks.AIR.defaultBlockState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEquivalentTo(Fluid fluidIn) {
|
||||
public boolean isSame(Fluid fluidIn) {
|
||||
return fluidIn == still.get() || fluidIn == flowing.get();
|
||||
}
|
||||
|
||||
@@ -155,16 +155,16 @@ public abstract class ForgeFlowingFluid extends FlowingFluid
|
||||
public Flowing(Properties properties)
|
||||
{
|
||||
super(properties);
|
||||
setDefaultState(getStateContainer().getBaseState().with(LEVEL_1_8, 7));
|
||||
registerDefaultState(getStateDefinition().any().setValue(LEVEL, 7));
|
||||
}
|
||||
|
||||
protected void fillStateContainer(StateContainer.Builder<Fluid, FluidState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(LEVEL_1_8);
|
||||
protected void createFluidStateDefinition(StateContainer.Builder<Fluid, FluidState> builder) {
|
||||
super.createFluidStateDefinition(builder);
|
||||
builder.add(LEVEL);
|
||||
}
|
||||
|
||||
public int getLevel(FluidState state) {
|
||||
return state.get(LEVEL_1_8);
|
||||
public int getAmount(FluidState state) {
|
||||
return state.getValue(LEVEL);
|
||||
}
|
||||
|
||||
public boolean isSource(FluidState state) {
|
||||
@@ -179,7 +179,7 @@ public abstract class ForgeFlowingFluid extends FlowingFluid
|
||||
super(properties);
|
||||
}
|
||||
|
||||
public int getLevel(FluidState state) {
|
||||
public int getAmount(FluidState state) {
|
||||
return 8;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,16 +44,16 @@ public class TileFluidHandler extends TileEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(BlockState state, CompoundNBT tag)
|
||||
public void load(BlockState state, CompoundNBT tag)
|
||||
{
|
||||
super.read(state, tag);
|
||||
super.load(state, tag);
|
||||
tank.readFromNBT(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT write(CompoundNBT tag)
|
||||
public CompoundNBT save(CompoundNBT tag)
|
||||
{
|
||||
tag = super.write(tag);
|
||||
tag = super.save(tag);
|
||||
tank.writeToNBT(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ import javax.annotation.Nullable;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
|
||||
|
||||
public class EmptyFluidHandler implements IFluidHandler
|
||||
{
|
||||
public static final EmptyFluidHandler INSTANCE = new EmptyFluidHandler();
|
||||
|
||||
+3
-1
@@ -32,6 +32,8 @@ import net.minecraftforge.fluids.*;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
|
||||
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
|
||||
|
||||
/**
|
||||
* FluidHandlerItemStack is a template capability provider for ItemStacks.
|
||||
* Data is stored directly in the vanilla NBT, in the same way as the old ItemFluidContainer.
|
||||
@@ -219,7 +221,7 @@ public class FluidHandlerItemStack implements IFluidHandlerItem, ICapabilityProv
|
||||
*/
|
||||
protected void setContainerToEmpty()
|
||||
{
|
||||
container.removeChildTag(FLUID_NBT_KEY);
|
||||
container.removeTagKey(FLUID_NBT_KEY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-1
@@ -32,6 +32,8 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
|
||||
|
||||
/**
|
||||
* FluidHandlerItemStackSimple is a template capability provider for ItemStacks.
|
||||
* Data is stored directly in the vanilla NBT, in the same way as the old ItemFluidContainer.
|
||||
@@ -196,7 +198,7 @@ public class FluidHandlerItemStackSimple implements IFluidHandlerItem, ICapabili
|
||||
*/
|
||||
protected void setContainerToEmpty()
|
||||
{
|
||||
container.removeChildTag(FLUID_NBT_KEY);
|
||||
container.removeTagKey(FLUID_NBT_KEY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,6 +25,8 @@ import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
|
||||
|
||||
/**
|
||||
* VoidFluidHandler is a template fluid handler that can be filled indefinitely without ever getting full.
|
||||
* It does not store fluid that gets filled into it, but "destroys" it upon receiving it.
|
||||
|
||||
@@ -29,6 +29,8 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fluids.capability.templates.VoidFluidHandler;
|
||||
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
|
||||
|
||||
/**
|
||||
* Wrapper around any block, only accounts for fluid placement, otherwise the block acts a void.
|
||||
* If the block in question inherits from the default Vanilla or Forge implementations,
|
||||
@@ -58,7 +60,7 @@ public class BlockWrapper extends VoidFluidHandler
|
||||
if (action.execute())
|
||||
{
|
||||
FluidUtil.destroyBlockOnFluidPlacement(world, blockPos);
|
||||
world.setBlockState(blockPos, state, Constants.BlockFlags.DEFAULT_AND_RERENDER);
|
||||
world.setBlock(blockPos, state, Constants.BlockFlags.DEFAULT_AND_RERENDER);
|
||||
}
|
||||
return FluidAttributes.BUCKET_VOLUME;
|
||||
}
|
||||
@@ -83,10 +85,10 @@ public class BlockWrapper extends VoidFluidHandler
|
||||
if (resource.getAmount() >= FluidAttributes.BUCKET_VOLUME)
|
||||
{
|
||||
BlockState state = world.getBlockState(blockPos);
|
||||
if (liquidContainer.canContainFluid(world, blockPos, state, resource.getFluid()))
|
||||
if (liquidContainer.canPlaceLiquid(world, blockPos, state, resource.getFluid()))
|
||||
{
|
||||
//If we are executing try to actually fill the container, if it failed return that we failed
|
||||
if (action.simulate() || liquidContainer.receiveFluid(world, blockPos, state, resource.getFluid().getAttributes().getStateForPlacement(world, blockPos, resource)))
|
||||
if (action.simulate() || liquidContainer.placeLiquid(world, blockPos, state, resource.getFluid().getAttributes().getStateForPlacement(world, blockPos, resource)))
|
||||
{
|
||||
return FluidAttributes.BUCKET_VOLUME;
|
||||
}
|
||||
|
||||
+9
-7
@@ -32,6 +32,8 @@ import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
|
||||
|
||||
public class BucketPickupHandlerWrapper implements IFluidHandler
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
@@ -63,7 +65,7 @@ public class BucketPickupHandlerWrapper implements IFluidHandler
|
||||
FluidState fluidState = world.getFluidState(blockPos);
|
||||
if (!fluidState.isEmpty())
|
||||
{
|
||||
return new FluidStack(fluidState.getFluid(), FluidAttributes.BUCKET_VOLUME);
|
||||
return new FluidStack(fluidState.getType(), FluidAttributes.BUCKET_VOLUME);
|
||||
}
|
||||
}
|
||||
return FluidStack.EMPTY;
|
||||
@@ -94,11 +96,11 @@ public class BucketPickupHandlerWrapper implements IFluidHandler
|
||||
if (!resource.isEmpty() && FluidAttributes.BUCKET_VOLUME <= resource.getAmount())
|
||||
{
|
||||
FluidState fluidState = world.getFluidState(blockPos);
|
||||
if (!fluidState.isEmpty() && resource.getFluid() == fluidState.getFluid())
|
||||
if (!fluidState.isEmpty() && resource.getFluid() == fluidState.getType())
|
||||
{
|
||||
if (action.execute())
|
||||
{
|
||||
Fluid fluid = bucketPickupHandler.pickupFluid(world, blockPos, world.getBlockState(blockPos));
|
||||
Fluid fluid = bucketPickupHandler.takeLiquid(world, blockPos, world.getBlockState(blockPos));
|
||||
if (fluid != Fluids.EMPTY)
|
||||
{
|
||||
FluidStack extracted = new FluidStack(fluid, FluidAttributes.BUCKET_VOLUME);
|
||||
@@ -106,7 +108,7 @@ public class BucketPickupHandlerWrapper implements IFluidHandler
|
||||
{
|
||||
//Be loud if something went wrong
|
||||
LOGGER.error("Fluid removed without successfully being picked up. Fluid {} at {} in {} matched requested type, but after performing pickup was {}.",
|
||||
fluidState.getFluid().getRegistryName(), blockPos, world.getDimensionKey().getLocation(), fluid.getRegistryName());
|
||||
fluidState.getType().getRegistryName(), blockPos, world.dimension().location(), fluid.getRegistryName());
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
return extracted;
|
||||
@@ -114,7 +116,7 @@ public class BucketPickupHandlerWrapper implements IFluidHandler
|
||||
}
|
||||
else
|
||||
{
|
||||
FluidStack extracted = new FluidStack(fluidState.getFluid(), FluidAttributes.BUCKET_VOLUME);
|
||||
FluidStack extracted = new FluidStack(fluidState.getType(), FluidAttributes.BUCKET_VOLUME);
|
||||
if (resource.isFluidEqual(extracted))
|
||||
{
|
||||
//Validate NBT matches
|
||||
@@ -137,9 +139,9 @@ public class BucketPickupHandlerWrapper implements IFluidHandler
|
||||
{
|
||||
if (action.simulate())
|
||||
{
|
||||
return new FluidStack(fluidState.getFluid(), FluidAttributes.BUCKET_VOLUME);
|
||||
return new FluidStack(fluidState.getType(), FluidAttributes.BUCKET_VOLUME);
|
||||
}
|
||||
Fluid fluid = bucketPickupHandler.pickupFluid(world, blockPos, world.getBlockState(blockPos));
|
||||
Fluid fluid = bucketPickupHandler.takeLiquid(world, blockPos, world.getBlockState(blockPos));
|
||||
if (fluid != Fluids.EMPTY)
|
||||
{
|
||||
return new FluidStack(fluid, FluidAttributes.BUCKET_VOLUME);
|
||||
|
||||
@@ -27,6 +27,8 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
|
||||
|
||||
public class FluidBlockWrapper implements IFluidHandler
|
||||
{
|
||||
protected final IFluidBlock fluidBlock;
|
||||
|
||||
@@ -36,6 +36,8 @@ import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
|
||||
|
||||
/**
|
||||
* Wrapper for vanilla and forge buckets.
|
||||
* Swaps between empty bucket and filled bucket of the correct type.
|
||||
|
||||
Reference in new issue
Block a user