-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve #334: no more material water hacks for the trample stone!
- Loading branch information
1 parent
d8f64d5
commit 6b1d0f0
Showing
3 changed files
with
59 additions
and
34 deletions.
There are no files selected for viewing
38 changes: 5 additions & 33 deletions
38
src/main/java/epicsquid/roots/block/runes/BlockTrample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,30 @@ | ||
package epicsquid.roots.block.runes; | ||
|
||
import epicsquid.mysticallib.block.BlockBase; | ||
import epicsquid.mysticallib.block.CustomStateMapper; | ||
import net.minecraft.block.BlockLiquid; | ||
import epicsquid.mysticallib.block.BlockTEBase; | ||
import net.minecraft.block.SoundType; | ||
import net.minecraft.block.material.Material; | ||
import net.minecraft.block.state.BlockStateContainer; | ||
import net.minecraft.block.state.IBlockState; | ||
import net.minecraft.client.renderer.block.model.ModelResourceLocation; | ||
import net.minecraft.client.renderer.block.statemap.StateMap; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.IBlockAccess; | ||
import net.minecraft.tileentity.TileEntity; | ||
import net.minecraftforge.client.model.ModelLoader; | ||
import net.minecraftforge.fml.relauncher.Side; | ||
import net.minecraftforge.fml.relauncher.SideOnly; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
@SuppressWarnings("deprecation") | ||
public class BlockTrample extends BlockBase { | ||
public class BlockTrample extends BlockTEBase { | ||
public static int SAFE_RANGE_X = 30; | ||
public static int SAFE_RANGE_Y = 5; | ||
public static int SAFE_RANGE_Z = 30; | ||
|
||
public BlockTrample(@Nonnull Material mat, @Nonnull SoundType type, float hardness, @Nonnull String name) { | ||
super(mat, type, hardness, name); | ||
setDefaultState(this.getDefaultState().withProperty(BlockLiquid.LEVEL, 15)); | ||
} | ||
|
||
@Override | ||
protected BlockStateContainer createBlockState() { | ||
return new BlockStateContainer(this, BlockLiquid.LEVEL); | ||
} | ||
|
||
@Override | ||
public IBlockState getStateFromMeta(int meta) { | ||
return this.getDefaultState().withProperty(BlockLiquid.LEVEL, meta); | ||
} | ||
|
||
@Override | ||
public int getMetaFromState(IBlockState state) { | ||
return state.getValue(BlockLiquid.LEVEL); | ||
} | ||
|
||
@Override | ||
public boolean isReplaceable(IBlockAccess worldIn, BlockPos pos) { | ||
return false; | ||
public BlockTrample(@Nonnull Material mat, @Nonnull SoundType type, float hardness, @Nonnull String name, @Nonnull Class<? extends TileEntity> teClass) { | ||
super(mat, type, hardness, name, teClass); | ||
} | ||
|
||
@Override | ||
@SideOnly(Side.CLIENT) | ||
public void initModel() { | ||
ModelLoader.setCustomStateMapper(this, new StateMap.Builder().ignore(BlockLiquid.LEVEL).build()); | ||
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(this), 0, new ModelResourceLocation(getRegistryName(), "handlers")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/main/java/epicsquid/roots/tileentity/TileEntityTrample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package epicsquid.roots.tileentity; | ||
|
||
import epicsquid.mysticallib.tile.TileBase; | ||
import net.minecraft.block.state.IBlockState; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.util.math.AxisAlignedBB; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
import net.minecraftforge.common.FarmlandWaterManager; | ||
import net.minecraftforge.common.ticket.AABBTicket; | ||
|
||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
|
||
public class TileEntityTrample extends TileBase { | ||
public static AxisAlignedBB BOUNDING_BOX = new AxisAlignedBB(-4, -1, -4, 4, 1, 4); | ||
|
||
private AABBTicket ticket = null; | ||
|
||
public TileEntityTrample() { | ||
} | ||
|
||
@Override | ||
public void breakBlock(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state, @Nullable EntityPlayer player) { | ||
super.breakBlock(world, pos, state, player); | ||
|
||
onChunkUnload(); | ||
} | ||
|
||
@Override | ||
public void onLoad() { | ||
super.onLoad(); | ||
|
||
if (world != null && !world.isRemote) { | ||
if (ticket != null) { | ||
ticket.validate(); | ||
} else { | ||
ticket = FarmlandWaterManager.addAABBTicket(world, BOUNDING_BOX.offset(getPos())); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void onChunkUnload() { | ||
super.onChunkUnload(); | ||
|
||
if (world != null && !world.isRemote) { | ||
if (ticket != null) { | ||
ticket.invalidate(); | ||
} | ||
} | ||
} | ||
} |