Added Custom Slime Block hook for Piston. (#4520)
This commit is contained in:
parent
4ab9929593
commit
02855f7d74
12 changed files with 199 additions and 3 deletions
|
@ -221,7 +221,7 @@
|
|||
public SoundType func_185467_w()
|
||||
{
|
||||
return this.field_149762_H;
|
||||
@@ -934,6 +952,1305 @@
|
||||
@@ -934,6 +952,1314 @@
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1522,12 +1522,21 @@
|
|||
+ return isSideSolid(blockState, world, pos, side);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * @param state The state
|
||||
+ * @return true if the block is sticky block which used for pull or push adjacent blocks (use by piston)
|
||||
+ */
|
||||
+ public boolean isStickyBlock(IBlockState state)
|
||||
+ {
|
||||
+ return state.func_177230_c() == Blocks.field_180399_cE;
|
||||
+ }
|
||||
+
|
||||
+ /* ========================================= FORGE END ======================================*/
|
||||
+
|
||||
public static void func_149671_p()
|
||||
{
|
||||
func_176215_a(0, field_176230_a, (new BlockAir()).func_149663_c("air"));
|
||||
@@ -1230,31 +2547,6 @@
|
||||
@@ -1230,31 +2556,6 @@
|
||||
block15.field_149783_u = flag;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
--- ../src-base/minecraft/net/minecraft/block/state/BlockPistonStructureHelper.java
|
||||
+++ ../src-work/minecraft/net/minecraft/block/state/BlockPistonStructureHelper.java
|
||||
@@ -65,7 +65,7 @@
|
||||
{
|
||||
BlockPos blockpos = this.field_177258_e.get(i);
|
||||
|
||||
- if (this.field_177261_a.func_180495_p(blockpos).func_177230_c() == Blocks.field_180399_cE && !this.func_177250_b(blockpos))
|
||||
+ if (this.field_177261_a.func_180495_p(blockpos).func_177230_c().isStickyBlock(this.field_177261_a.func_180495_p(blockpos)) && !this.func_177250_b(blockpos))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -80,7 +80,7 @@
|
||||
IBlockState iblockstate = this.field_177261_a.func_180495_p(p_177251_1_);
|
||||
Block block = iblockstate.func_177230_c();
|
||||
|
@ -9,7 +18,14 @@
|
|||
{
|
||||
return true;
|
||||
}
|
||||
@@ -112,7 +112,7 @@
|
||||
@@ -106,13 +106,13 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
- while (block == Blocks.field_180399_cE)
|
||||
+ while (block.isStickyBlock(iblockstate))
|
||||
{
|
||||
BlockPos blockpos = p_177251_1_.func_177967_a(this.field_177257_d.func_176734_d(), i);
|
||||
iblockstate = this.field_177261_a.func_180495_p(blockpos);
|
||||
block = iblockstate.func_177230_c();
|
||||
|
||||
|
@ -18,6 +34,15 @@
|
|||
{
|
||||
break;
|
||||
}
|
||||
@@ -148,7 +148,7 @@
|
||||
{
|
||||
BlockPos blockpos2 = this.field_177258_e.get(l);
|
||||
|
||||
- if (this.field_177261_a.func_180495_p(blockpos2).func_177230_c() == Blocks.field_180399_cE && !this.func_177250_b(blockpos2))
|
||||
+ if (this.field_177261_a.func_180495_p(blockpos2).func_177230_c().isStickyBlock(this.field_177261_a.func_180495_p(blockpos2)) && !this.func_177250_b(blockpos2))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -159,7 +159,7 @@
|
||||
|
||||
iblockstate = this.field_177261_a.func_180495_p(blockpos1);
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
--- ../src-base/minecraft/net/minecraft/tileentity/TileEntityPiston.java
|
||||
+++ ../src-work/minecraft/net/minecraft/tileentity/TileEntityPiston.java
|
||||
@@ -145,7 +145,7 @@
|
||||
|
||||
if (!list1.isEmpty())
|
||||
{
|
||||
- boolean flag = this.field_174932_a.func_177230_c() == Blocks.field_180399_cE;
|
||||
+ boolean flag = this.field_174932_a.func_177230_c().isStickyBlock(this.field_174932_a);
|
||||
|
||||
for (int i = 0; i < list1.size(); ++i)
|
||||
{
|
123
src/test/java/net/minecraftforge/debug/CustomSlimeBlockTest.java
Normal file
123
src/test/java/net/minecraftforge/debug/CustomSlimeBlockTest.java
Normal file
|
@ -0,0 +1,123 @@
|
|||
package net.minecraftforge.debug;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockSlime;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemMultiTexture;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@Mod(modid = CustomSlimeBlockTest.MODID, name = "ForgeDebugCustomSlimeBlock", version = CustomSlimeBlockTest.VERSION, acceptableRemoteVersions = "*")
|
||||
public class CustomSlimeBlockTest
|
||||
{
|
||||
public static final String MODID = "forgedebugcustomslimeblock";
|
||||
public static final String ASSETS = "forgedebugcustomslimeblock:";
|
||||
public static final String VERSION = "1.0";
|
||||
public static Block CUSTOM_SLIME_BLOCK;
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
CUSTOM_SLIME_BLOCK = new CustomSlime();
|
||||
ForgeRegistries.BLOCKS.register(CUSTOM_SLIME_BLOCK);
|
||||
ForgeRegistries.ITEMS.register(new ItemMultiTexture(CUSTOM_SLIME_BLOCK, CUSTOM_SLIME_BLOCK, stack -> CustomSlime.BlockType.values[stack.getMetadata()].toString()).setRegistryName(CUSTOM_SLIME_BLOCK.getRegistryName()));
|
||||
}
|
||||
|
||||
@EventBusSubscriber(value = Side.CLIENT, modid = MODID)
|
||||
public static class BakeEventHandler
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void registerModels(ModelRegistryEvent event)
|
||||
{
|
||||
Item item = Item.getItemFromBlock(CUSTOM_SLIME_BLOCK);
|
||||
ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(ASSETS + "blue_slime_block", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(item, 1, new ModelResourceLocation(ASSETS + "obsidian_slime_block", "inventory"));
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomSlime extends BlockSlime
|
||||
{
|
||||
private static final PropertyEnum<BlockType> VARIANT = PropertyEnum.create("variant", BlockType.class);
|
||||
|
||||
private CustomSlime()
|
||||
{
|
||||
super();
|
||||
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, BlockType.BLUE_SLIME_BLOCK));
|
||||
this.setCreativeTab(CreativeTabs.DECORATIONS);
|
||||
this.setUnlocalizedName("custom_slime_block");
|
||||
this.setRegistryName("forgedebugcustomslimeblock:custom_slime_block");
|
||||
this.setSoundType(SoundType.SLIME);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(CreativeTabs creativeTabs, NonNullList<ItemStack> list)
|
||||
{
|
||||
for (int i = 0; i < BlockType.values.length; ++i)
|
||||
{
|
||||
list.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
return new BlockStateContainer(this, VARIANT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta)
|
||||
{
|
||||
return this.getDefaultState().withProperty(VARIANT, BlockType.values[meta]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state)
|
||||
{
|
||||
return state.getValue(VARIANT).ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStickyBlock(IBlockState state)
|
||||
{
|
||||
return state.getValue(VARIANT) != BlockType.OBSIDIAN_SLIME_BLOCK;
|
||||
}
|
||||
|
||||
public static enum BlockType implements IStringSerializable
|
||||
{
|
||||
BLUE_SLIME_BLOCK,
|
||||
OBSIDIAN_SLIME_BLOCK;
|
||||
|
||||
protected static final BlockType[] values = BlockType.values();
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"variants": {
|
||||
"variant=blue_slime_block": { "model": "forgedebugcustomslimeblock:blue_slime_block" },
|
||||
"variant=obsidian_slime_block": { "model": "forgedebugcustomslimeblock:obsidian_slime_block" }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
tile.custom_slime_block.blue_slime_block.name=Blue Slime Block
|
||||
tile.custom_slime_block.obsidian_slime_block.name=Obsidian Slime Block
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"parent": "block/slime",
|
||||
"textures": {
|
||||
"particle": "forgedebugcustomslimeblock:blocks/blue_slime_block",
|
||||
"texture": "forgedebugcustomslimeblock:blocks/blue_slime_block"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"parent": "block/slime",
|
||||
"textures": {
|
||||
"particle": "forgedebugcustomslimeblock:blocks/obsidian_slime_block",
|
||||
"texture": "forgedebugcustomslimeblock:blocks/obsidian_slime_block"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"parent": "forgedebugcustomslimeblock:block/blue_slime_block"
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"parent": "forgedebugcustomslimeblock:block/obsidian_slime_block"
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 753 B |
Binary file not shown.
After Width: | Height: | Size: 719 B |
Loading…
Reference in a new issue