Portal trigger no longer uses fluid stacks
This commit is contained in:
parent
b2413b637b
commit
001396d754
1 changed files with 21 additions and 20 deletions
|
@ -16,6 +16,7 @@ import net.minecraft.util.EnumParticleTypes;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.RayTraceResult;
|
import net.minecraft.util.math.RayTraceResult;
|
||||||
import net.minecraft.util.math.RayTraceResult.Type;
|
import net.minecraft.util.math.RayTraceResult.Type;
|
||||||
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
||||||
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
|
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
|
||||||
import net.minecraftforge.event.entity.player.FillBucketEvent;
|
import net.minecraftforge.event.entity.player.FillBucketEvent;
|
||||||
|
@ -64,64 +65,64 @@ public class AetherEventHandler
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onFillBucket(FillBucketEvent event)
|
public void onFillBucket(FillBucketEvent event)
|
||||||
{
|
{
|
||||||
@Nullable FluidStack fluid = FluidUtil.getFluidContained(event.getEmptyBucket());
|
ItemStack stack = event.getEmptyBucket();
|
||||||
|
|
||||||
if (fluid == null || fluid.getFluid() == null || event.getEmptyBucket() == null)
|
if (stack == null)
|
||||||
{
|
{
|
||||||
event.setResult(Result.DENY);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
World worldObj = event.getWorld();
|
||||||
RayTraceResult target = event.getTarget();
|
RayTraceResult target = event.getTarget();
|
||||||
EntityPlayer player = event.getEntityPlayer();
|
EntityPlayer player = event.getEntityPlayer();
|
||||||
|
|
||||||
boolean isWater = fluid.getFluid() == FluidRegistry.WATER;
|
boolean isWater = stack.getItem() == Items.WATER_BUCKET || stack.getItem() == ItemsAether.skyroot_bucket && stack.getMetadata() == 1;
|
||||||
boolean isLava = fluid.getFluid() == FluidRegistry.LAVA;
|
boolean isLava = stack.getItem() == Items.LAVA_BUCKET;
|
||||||
|
|
||||||
boolean validDimension = (player.dimension == 0 || player.dimension == AetherConfig.getAetherDimensionID());
|
boolean validDimension = (player.dimension == 0 || player.dimension == AetherConfig.getAetherDimensionID());
|
||||||
|
|
||||||
if (target != null && target.typeOfHit == Type.BLOCK && validDimension)
|
if (target != null && target.typeOfHit == Type.BLOCK && validDimension)
|
||||||
{
|
{
|
||||||
BlockPos hitPos = event.getTarget().getBlockPos().offset(event.getTarget().sideHit);
|
BlockPos hitPos = target.getBlockPos().offset(target.sideHit);
|
||||||
|
|
||||||
if (isWater)
|
if (isWater)
|
||||||
{
|
{
|
||||||
if (((BlockAetherPortal) BlocksAether.aether_portal).trySpawnPortal(event.getWorld(), hitPos))
|
if (((BlockAetherPortal) BlocksAether.aether_portal).trySpawnPortal(worldObj, hitPos))
|
||||||
{
|
{
|
||||||
if (!event.getEntityPlayer().capabilities.isCreativeMode)
|
if (!player.capabilities.isCreativeMode)
|
||||||
{
|
{
|
||||||
if (event.getEmptyBucket().getItem() == ItemsAether.skyroot_bucket || event.getEmptyBucket().getItemDamage() == 1)
|
if (stack.getItem() == ItemsAether.skyroot_bucket || stack.getItemDamage() == 1)
|
||||||
{
|
{
|
||||||
event.setFilledBucket(new ItemStack(ItemsAether.skyroot_bucket));
|
event.setFilledBucket(new ItemStack(ItemsAether.skyroot_bucket));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getEmptyBucket().getItem() == Items.WATER_BUCKET)
|
if (stack.getItem() == Items.WATER_BUCKET)
|
||||||
{
|
{
|
||||||
event.setFilledBucket(new ItemStack(Items.BUCKET));
|
event.setFilledBucket(new ItemStack(Items.BUCKET));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
event.setResult(Result.ALLOW);
|
event.setResult(Result.ALLOW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isLava && player.dimension == AetherConfig.getAetherDimensionID())
|
if (isLava && player.dimension == AetherConfig.getAetherDimensionID())
|
||||||
{
|
{
|
||||||
if (event.getEntityPlayer().capabilities.isCreativeMode && event.getEntityPlayer().isSneaking())
|
if (player.capabilities.isCreativeMode && player.isSneaking())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!event.getWorld().isRemote)
|
if (worldObj.isAirBlock(hitPos))
|
||||||
{
|
{
|
||||||
if (event.getWorld().isAirBlock(hitPos))
|
worldObj.setBlockState(hitPos, BlocksAether.aerogel.getDefaultState());
|
||||||
{
|
|
||||||
event.getWorld().setBlockState(hitPos, BlocksAether.aerogel.getDefaultState());
|
|
||||||
|
|
||||||
if (!event.getEntityPlayer().capabilities.isCreativeMode)
|
if (!player.capabilities.isCreativeMode)
|
||||||
{
|
{
|
||||||
event.setFilledBucket(new ItemStack(Items.BUCKET));
|
event.setFilledBucket(new ItemStack(Items.BUCKET));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
event.setResult(Result.ALLOW);
|
event.setResult(Result.ALLOW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue