Port to 1.11
This commit is contained in:
parent
122fd9c6c9
commit
d1a69c8231
|
@ -68,7 +68,7 @@ curseforge {
|
|||
project {
|
||||
id = "246215"
|
||||
|
||||
addGameVersion "1.10.2"
|
||||
addGameVersion "1.11"
|
||||
addGameVersion "Java 8"
|
||||
|
||||
mainArtifact(jar) {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
mod_version = 1.1.1
|
||||
mod_version = 1.2.0
|
||||
group = net.shadowfacts
|
||||
archivesBaseName = Funnels
|
||||
|
||||
mc_version = 1.10.2
|
||||
mcp_mappings = snapshot_20160705
|
||||
forge_version = 12.18.0.2007-1.10.0
|
||||
mc_version = 1.11
|
||||
mcp_mappings = snapshot_20161120
|
||||
forge_version = 13.19.0.2153
|
||||
|
||||
shadowmc_version = 3.4.0
|
||||
jei_version = 3.7.3.223
|
||||
shadowmc_version = 3.7.0
|
||||
jei_version = 4.0.2.194
|
||||
|
|
|
@ -16,6 +16,9 @@ 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.fluids.FluidActionResult;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.shadowfacts.shadowmc.block.BlockTE;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -78,21 +81,19 @@ public class BlockFunnel extends BlockTE<TileEntityFunnel> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public IBlockState onBlockPlaced(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {
|
||||
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) {
|
||||
EnumFacing side = facing.getOpposite();
|
||||
if (side == EnumFacing.UP) side = EnumFacing.DOWN;
|
||||
return getDefaultState().withProperty(FACING, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing heldItem, float side, float hitX, float hitY) {
|
||||
if (!player.isSneaking()) {
|
||||
TileEntityFunnel te = getTileEntity(world, pos);
|
||||
|
||||
if (FluidUtils.fillHandlerWithContainer(world, te.tank, player, hand)) {
|
||||
te.save();
|
||||
return true;
|
||||
} else if (FluidUtils.fillContainerFromHandler(world, te.tank, player, hand, te.tank.getFluid())) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
FluidActionResult result = FluidUtil.interactWithFluidHandler(stack, te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.NORTH), player);
|
||||
if (result.isSuccess()) {
|
||||
te.save();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -17,62 +17,6 @@ import net.minecraftforge.fluids.capability.IFluidHandler;
|
|||
*/
|
||||
public class FluidUtils {
|
||||
|
||||
public static boolean fillHandlerWithContainer(World world, IFluidHandler handler, EntityPlayer player, EnumHand hand) {
|
||||
ItemStack container = player.getHeldItem(hand);
|
||||
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(container);
|
||||
|
||||
if (fluid != null) {
|
||||
if (handler.fill(fluid, false) == fluid.amount || player.capabilities.isCreativeMode) {
|
||||
ItemStack returnStack = FluidContainerRegistry.drainFluidContainer(container);
|
||||
if (world.isRemote) {
|
||||
return true;
|
||||
}
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
if (PlayerUtils.disposePlayerItem(player.getHeldItem(hand), returnStack, player, true)) {
|
||||
player.openContainer.detectAndSendChanges();
|
||||
((EntityPlayerMP)player).sendContainerToPlayer(player.openContainer);
|
||||
}
|
||||
}
|
||||
handler.fill(fluid, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean fillContainerFromHandler(World world, IFluidHandler handler, EntityPlayer player, EnumHand hand, FluidStack tankFluid) {
|
||||
ItemStack container = player.getHeldItem(hand);
|
||||
|
||||
if (FluidContainerRegistry.isEmptyContainer(container)) {
|
||||
ItemStack returnStack = FluidContainerRegistry.fillFluidContainer(tankFluid, container);
|
||||
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(returnStack);
|
||||
|
||||
if (fluid == null || returnStack == null) {
|
||||
return false;
|
||||
}
|
||||
if (world.isRemote) {
|
||||
return true;
|
||||
}
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
if (container.stackSize == 1) {
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, returnStack);
|
||||
container.stackSize--;
|
||||
if (container.stackSize <= 0) {
|
||||
container = null;
|
||||
}
|
||||
} else {
|
||||
if (PlayerUtils.disposePlayerItem(player.getHeldItem(hand), returnStack, player, true)) {
|
||||
player.openContainer.detectAndSendChanges();
|
||||
((EntityPlayerMP) player).sendContainerToPlayer(player.openContainer);
|
||||
}
|
||||
}
|
||||
}
|
||||
handler.drain(fluid.amount, true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isFluidBlock(World world, BlockPos pos) {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
if (state.getBlock() instanceof BlockLiquid) {
|
||||
|
|
|
@ -13,7 +13,7 @@ import net.minecraftforge.oredict.ShapedOreRecipe;
|
|||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
@Mod(modid = Funnels.modId, name = Funnels.name, version = Funnels.version, dependencies = "required-after:shadowmc@[3.4.0,);", acceptedMinecraftVersions = "[1.10.2]", guiFactory = "net.shadowfacts.funnels.GUIFactory")
|
||||
@Mod(modid = Funnels.modId, name = Funnels.name, version = Funnels.version, dependencies = "required-after:shadowmc@[3.4.0,);", guiFactory = "net.shadowfacts.funnels.GUIFactory")
|
||||
public class Funnels {
|
||||
|
||||
public static final String modId = "Funnels";
|
||||
|
|
|
@ -13,12 +13,12 @@ public class PlayerUtils {
|
|||
if (entityplayer == null || entityplayer.capabilities.isCreativeMode) {
|
||||
return true;
|
||||
}
|
||||
if (allowReplace && stack.stackSize <= 1) {
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, null);
|
||||
if (allowReplace && stack.getCount() <= 1) {
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, ItemStack.EMPTY);
|
||||
entityplayer.inventory.addItemStackToInventory(dropStack);
|
||||
return true;
|
||||
} else if (allowDrop) {
|
||||
stack.stackSize -= 1;
|
||||
stack.shrink(1);
|
||||
if (dropStack != null && !entityplayer.inventory.addItemStackToInventory(dropStack)) {
|
||||
entityplayer.dropItem(dropStack, false, true);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ public class TESRFunnel extends TileEntitySpecialRenderer<TileEntityFunnel> {
|
|||
renderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
|
||||
int color = fluid.getFluid().getColor(fluid);
|
||||
int brightness = Minecraft.getMinecraft().theWorld.getCombinedLight(te.getPos(), fluid.getFluid().getLuminosity());
|
||||
int brightness = Minecraft.getMinecraft().world.getCombinedLight(te.getPos(), fluid.getFluid().getLuminosity());
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
|
||||
|
|
|
@ -31,18 +31,18 @@ public class TileEntityFunnel extends BaseTileEntity implements ITickable {
|
|||
|
||||
void save() {
|
||||
markDirty();
|
||||
ShadowMC.network.sendToAllAround(new PacketUpdateTE(this), new NetworkRegistry.TargetPoint(worldObj.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), 64));
|
||||
ShadowMC.network.sendToAllAround(new PacketUpdateTE(this), new NetworkRegistry.TargetPoint(world.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), 64));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (!worldObj.isRemote) {
|
||||
if (!world.isRemote) {
|
||||
handlers:
|
||||
{
|
||||
// up handler -> tank
|
||||
if (tank.getFluidAmount() < tank.getCapacity()) {
|
||||
BlockPos handlerPos = pos.up();
|
||||
TileEntity te = worldObj.getTileEntity(handlerPos);
|
||||
TileEntity te = world.getTileEntity(handlerPos);
|
||||
if (te != null && te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.DOWN)) {
|
||||
IFluidHandler handler = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.DOWN);
|
||||
tank.fill(handler.drain(tank.getCapacity() - tank.getFluidAmount(), true), true);
|
||||
|
@ -52,9 +52,9 @@ public class TileEntityFunnel extends BaseTileEntity implements ITickable {
|
|||
}
|
||||
// tank -> front handler
|
||||
if (tank.getFluidAmount() > 0) {
|
||||
EnumFacing facing = worldObj.getBlockState(pos).getValue(BlockFunnel.FACING);
|
||||
EnumFacing facing = world.getBlockState(pos).getValue(BlockFunnel.FACING);
|
||||
BlockPos handlerPos = pos.offset(facing);
|
||||
TileEntity te = worldObj.getTileEntity(handlerPos);
|
||||
TileEntity te = world.getTileEntity(handlerPos);
|
||||
if (te != null && te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing.getOpposite())) {
|
||||
IFluidHandler handler = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing.getOpposite());
|
||||
tank.drain(handler.fill(tank.drain(20, false), true), true);
|
||||
|
@ -70,10 +70,10 @@ public class TileEntityFunnel extends BaseTileEntity implements ITickable {
|
|||
// pickup from world
|
||||
if (FunnelsConfig.pickupWorldFluids && tank.getFluidAmount() <= tank.getCapacity() - Fluid.BUCKET_VOLUME) {
|
||||
tick = 0;
|
||||
if (FluidUtils.isFluidBlock(worldObj, pos.up())) {
|
||||
FluidStack toDrain = FluidUtils.drainFluidBlock(worldObj, pos.up(), false);
|
||||
if (FluidUtils.isFluidBlock(world, pos.up())) {
|
||||
FluidStack toDrain = FluidUtils.drainFluidBlock(world, pos.up(), false);
|
||||
if (toDrain.amount <= tank.getCapacity() - tank.getFluidAmount()) {
|
||||
tank.fill(FluidUtils.drainFluidBlock(worldObj, pos.up(), true), true);
|
||||
tank.fill(FluidUtils.drainFluidBlock(world, pos.up(), true), true);
|
||||
save();
|
||||
break world;
|
||||
}
|
||||
|
@ -84,11 +84,11 @@ public class TileEntityFunnel extends BaseTileEntity implements ITickable {
|
|||
FluidStack fluid = tank.getFluid();
|
||||
if (fluid.getFluid().canBePlacedInWorld()) {
|
||||
Block fluidBlock = fluid.getFluid().getBlock();
|
||||
BlockPos newPos = pos.offset(worldObj.getBlockState(pos).getValue(BlockFunnel.FACING));
|
||||
if (fluidBlock.canPlaceBlockAt(worldObj, newPos)) {
|
||||
BlockPos newPos = pos.offset(world.getBlockState(pos).getValue(BlockFunnel.FACING));
|
||||
if (fluidBlock.canPlaceBlockAt(world, newPos)) {
|
||||
tank.drain(Fluid.BUCKET_VOLUME, true);
|
||||
save();
|
||||
worldObj.setBlockState(newPos, fluidBlock.getDefaultState());
|
||||
world.setBlockState(newPos, fluidBlock.getDefaultState());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue