mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-08 06:26:43 +01:00
The fattening! Fatten out all the loud locks!
This commit is contained in:
parent
5108afc19f
commit
710e7503cf
53 changed files with 532 additions and 260 deletions
106
src/main/java/com/minelittlepony/unicopia/Fixes.java
Normal file
106
src/main/java/com/minelittlepony/unicopia/Fixes.java
Normal file
|
@ -0,0 +1,106 @@
|
|||
package com.minelittlepony.unicopia;
|
||||
|
||||
import com.minelittlepony.unicopia.init.UBlocks;
|
||||
import com.minelittlepony.util.fixers.BlockFixer;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.datafix.DataFixer;
|
||||
import net.minecraft.util.datafix.FixTypes;
|
||||
import net.minecraft.util.datafix.IFixableData;
|
||||
import net.minecraftforge.common.util.CompoundDataFixer;
|
||||
import net.minecraftforge.common.util.ModFixs;
|
||||
|
||||
public class Fixes {
|
||||
|
||||
static void init(DataFixer fixer) {
|
||||
|
||||
CompoundDataFixer forgeDataFixer = (CompoundDataFixer)fixer;
|
||||
|
||||
try {
|
||||
ModFixs modfix = forgeDataFixer.init(Unicopia.MODID, 1342);
|
||||
|
||||
modfix.registerFix(FixTypes.CHUNK, new FixCloudBlocks());
|
||||
modfix.registerFix(FixTypes.ITEM_INSTANCE, new FixCloudItems());
|
||||
} catch (Throwable ignored) {
|
||||
// no way to check if our fixer is already registered.
|
||||
// so just do it anyway and ignore the error.
|
||||
// @FUF(reason = "FUF")
|
||||
}
|
||||
}
|
||||
|
||||
static class FixCloudItems implements IFixableData {
|
||||
@Override
|
||||
public int getFixVersion() {
|
||||
return 1342;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound fixTagCompound(NBTTagCompound compound) {
|
||||
|
||||
if (compound.hasKey("id", 8) && compound.hasKey("Damage", 3)) {
|
||||
String id = compound.getString("id");
|
||||
int damage = compound.getInteger("Damage");
|
||||
|
||||
if (id == "unicopia:cloud_block") {
|
||||
if (damage == 1) {
|
||||
damage = 0;
|
||||
id = "unicopia:packed_cloud_block";
|
||||
} else if (damage == 2) {
|
||||
damage = 0;
|
||||
id = "unicopia:enchanted_cloud_block";
|
||||
}
|
||||
}
|
||||
|
||||
if (id == "unicopia:cloud_slab") {
|
||||
if (damage == 1) {
|
||||
damage = 0;
|
||||
id = "unicopia:packed_cloud_slab";
|
||||
} else if (damage == 2) {
|
||||
damage = 0;
|
||||
id = "unicopia:enchanted_cloud_slab";
|
||||
}
|
||||
}
|
||||
|
||||
compound.setString("id", id);
|
||||
compound.setInteger("Damage", 0);
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
|
||||
static class FixCloudBlocks extends BlockFixer {
|
||||
|
||||
@Override
|
||||
public int getFixVersion() {
|
||||
return 1342;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IBlockState fixBlockState(int id, int metadata) {
|
||||
if (id == Block.getIdFromBlock(UBlocks.normal_cloud) && metadata != 0) {
|
||||
if (metadata == 1) {
|
||||
return UBlocks.packed_cloud.getDefaultState();
|
||||
}
|
||||
if (metadata == 2) {
|
||||
return UBlocks.enchanted_cloud.getDefaultState();
|
||||
}
|
||||
}
|
||||
|
||||
int shifted = metadata % 8;
|
||||
|
||||
if (id == Block.getIdFromBlock(UBlocks.cloud_slab) && shifted != 0) {
|
||||
if (shifted == 1) {
|
||||
return UBlocks.packed_cloud_slab.getStateFromMeta(metadata - shifted);
|
||||
}
|
||||
if (shifted == 2) {
|
||||
return UBlocks.enchanted_cloud_slab.getStateFromMeta(metadata - shifted);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,6 +11,7 @@ import net.minecraftforge.fml.common.Mod.EventHandler;
|
|||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLServerAboutToStartEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
|
||||
import net.minecraftforge.fml.common.network.IGuiHandler;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
|
@ -75,6 +76,11 @@ public class Unicopia implements IGuiHandler {
|
|||
MinecraftForge.TERRAIN_GEN_BUS.register(Hooks.class);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onServerCreated(FMLServerAboutToStartEvent event) {
|
||||
Fixes.init(event.getServer().getDataFixer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onServerStart(FMLServerStartingEvent event) {
|
||||
Commands.init(event);
|
||||
|
|
|
@ -11,48 +11,47 @@ import com.minelittlepony.unicopia.player.PlayerSpeciesList;
|
|||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockCloud extends Block implements ICloudBlock, ITillable {
|
||||
|
||||
public static final PropertyEnum<CloudType> VARIANT = PropertyEnum.create("variant", CloudType.class);
|
||||
private final CloudType variant;
|
||||
|
||||
public BlockCloud(Material material, String domain, String name) {
|
||||
public BlockCloud(Material material, CloudType variant, String domain, String name) {
|
||||
super(material);
|
||||
setRegistryName(domain, name);
|
||||
setTranslationKey(name);
|
||||
|
||||
setCreativeTab(CreativeTabs.MISC);
|
||||
setCreativeTab(CreativeTabs.MATERIALS);
|
||||
setHardness(0.5f);
|
||||
setResistance(1.0F);
|
||||
setSoundType(SoundType.CLOTH);
|
||||
setLightOpacity(20);
|
||||
useNeighborBrightness = true;
|
||||
|
||||
this.variant = variant;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTranslucent(IBlockState state) {
|
||||
return true;
|
||||
return variant == CloudType.NORMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(IBlockState state) {
|
||||
return false;
|
||||
return variant != CloudType.NORMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -73,7 +72,7 @@ public class BlockCloud extends Block implements ICloudBlock, ITillable {
|
|||
|
||||
@Override
|
||||
public BlockRenderLayer getRenderLayer() {
|
||||
return BlockRenderLayer.TRANSLUCENT;
|
||||
return variant == CloudType.NORMAL ? BlockRenderLayer.TRANSLUCENT : super.getRenderLayer();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
|
@ -144,36 +143,9 @@ public class BlockCloud extends Block implements ICloudBlock, ITillable {
|
|||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(IBlockState state) {
|
||||
return ((CloudType)state.getValue(VARIANT)).getMetadata();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
|
||||
for (CloudType i : CloudType.values()) {
|
||||
list.add(new ItemStack(this, 1, i.getMetadata()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
return getDefaultState().withProperty(VARIANT, CloudType.byMetadata(meta));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
return ((CloudType)state.getValue(VARIANT)).getMetadata();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, VARIANT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CloudType getCloudMaterialType(IBlockState blockState) {
|
||||
return (CloudType)blockState.getValue(VARIANT);
|
||||
return variant;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
|
|
|
@ -4,6 +4,9 @@ import java.util.List;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.CloudType;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
|
@ -43,8 +46,8 @@ public class BlockCloudBanister extends BlockCloudFence {
|
|||
new AxisAlignedBB(0, 0, 0, 1, h, 1)
|
||||
};
|
||||
|
||||
public BlockCloudBanister(String domain, String name) {
|
||||
super(domain, name);
|
||||
public BlockCloudBanister(Material material, String domain, String name) {
|
||||
super(material, CloudType.ENCHANTED, domain, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -120,6 +120,6 @@ public class BlockCloudFarm extends UFarmland implements ICloudBlock {
|
|||
|
||||
@Override
|
||||
protected IBlockState getDroppedState(IBlockState state) {
|
||||
return UBlocks.cloud.getDefaultState();
|
||||
return UBlocks.normal_cloud.getDefaultState();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,10 +5,10 @@ import java.util.List;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.CloudType;
|
||||
import com.minelittlepony.unicopia.init.UMaterials;
|
||||
|
||||
import net.minecraft.block.BlockFence;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -23,8 +23,10 @@ import net.minecraft.world.World;
|
|||
|
||||
public class BlockCloudFence extends BlockFence implements ICloudBlock {
|
||||
|
||||
public BlockCloudFence(String domain, String name) {
|
||||
super(UMaterials.cloud, UMaterials.cloud.getMaterialMapColor());
|
||||
private final CloudType variant;
|
||||
|
||||
public BlockCloudFence(Material material, CloudType variant, String domain, String name) {
|
||||
super(material, material.getMaterialMapColor());
|
||||
setTranslationKey(name);
|
||||
setRegistryName(domain, name);
|
||||
|
||||
|
@ -33,16 +35,18 @@ public class BlockCloudFence extends BlockFence implements ICloudBlock {
|
|||
setLightOpacity(20);
|
||||
setSoundType(SoundType.CLOTH);
|
||||
useNeighborBrightness = true;
|
||||
|
||||
this.variant = variant;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTranslucent(IBlockState state) {
|
||||
return true;
|
||||
return variant == CloudType.NORMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(IBlockState state) {
|
||||
return false;
|
||||
return variant != CloudType.NORMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -62,12 +66,12 @@ public class BlockCloudFence extends BlockFence implements ICloudBlock {
|
|||
|
||||
@Override
|
||||
public CloudType getCloudMaterialType(IBlockState blockState) {
|
||||
return CloudType.NORMAL;
|
||||
return variant;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderLayer getRenderLayer() {
|
||||
return BlockRenderLayer.TRANSLUCENT;
|
||||
return variant == CloudType.NORMAL ? BlockRenderLayer.TRANSLUCENT : super.getRenderLayer();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,8 +6,8 @@ import java.util.Random;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.CloudType;
|
||||
import com.minelittlepony.unicopia.init.UBlocks;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockSlab;
|
||||
import net.minecraft.block.BlockStairs;
|
||||
import net.minecraft.block.SoundType;
|
||||
|
@ -23,7 +23,7 @@ import net.minecraft.item.Item;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
|
@ -31,54 +31,61 @@ import net.minecraft.util.math.Vec3d;
|
|||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockCloudSlab extends BlockSlab implements ICloudBlock {
|
||||
public abstract class BlockCloudSlab<T extends Block & ICloudBlock> extends BlockSlab implements ICloudBlock {
|
||||
|
||||
public static final PropertyEnum<CloudType> VARIANT = PropertyEnum.create("variant", CloudType.class);
|
||||
public static final PropertyEnum<Variant> VARIANT = PropertyEnum.<Variant>create("variant", Variant.class);
|
||||
|
||||
private boolean isDouble;
|
||||
protected final T modelBlock;
|
||||
|
||||
public BlockCloudSlab(boolean isDouble, Material material, String domain, String name) {
|
||||
public BlockCloudSlab(T modelBlock, BlockCloudSlab<? extends T> single, Material material, String domain, String name) {
|
||||
super(material);
|
||||
|
||||
setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
|
||||
setHardness(0.5F);
|
||||
setResistance(1.0F);
|
||||
setResistance(1);
|
||||
setSoundType(SoundType.CLOTH);
|
||||
setLightOpacity(20);
|
||||
setTranslationKey(name);
|
||||
setRegistryName(domain, name);
|
||||
this.isDouble = isDouble;
|
||||
|
||||
useNeighborBrightness = true;
|
||||
|
||||
this.modelBlock = modelBlock;
|
||||
this.fullBlock = isDouble();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean isTranslucent(IBlockState state) {
|
||||
return UBlocks.cloud.isTranslucent(state);
|
||||
return modelBlock.isTranslucent(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAir(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return allowsFallingBlockToPass(state, world, pos);
|
||||
return modelBlock.isAir(state, world, pos);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean isOpaqueCube(IBlockState state) {
|
||||
return isDouble() ? UBlocks.cloud.isOpaqueCube(state) : false;
|
||||
return isDouble() && modelBlock != null && modelBlock.isOpaqueCube(state);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean isFullCube(IBlockState state) {
|
||||
return isDouble() ? UBlocks.cloud.isFullCube(state) : false;
|
||||
return isDouble() && modelBlock.isFullCube(state);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean isNormalCube(IBlockState state) {
|
||||
return isDouble() ? UBlocks.cloud.isNormalCube(state) : false;
|
||||
return isDouble() && modelBlock.isNormalCube(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderLayer getRenderLayer() {
|
||||
return UBlocks.cloud.getRenderLayer();
|
||||
return modelBlock.getRenderLayer();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -88,17 +95,17 @@ public class BlockCloudSlab extends BlockSlab implements ICloudBlock {
|
|||
|
||||
@Override
|
||||
public void onFallenUpon(World w, BlockPos pos, Entity entity, float fallDistance) {
|
||||
UBlocks.cloud.onFallenUpon(w, pos, entity, fallDistance);
|
||||
modelBlock.onFallenUpon(w, pos, entity, fallDistance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLanded(World w, Entity entity) {
|
||||
UBlocks.cloud.onLanded(w, entity);
|
||||
modelBlock.onLanded(w, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollision(World w, BlockPos pos, IBlockState state, Entity entity) {
|
||||
UBlocks.cloud.onEntityCollision(w, pos, state, entity);
|
||||
modelBlock.onEntityCollision(w, pos, state, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -121,7 +128,121 @@ public class BlockCloudSlab extends BlockSlab implements ICloudBlock {
|
|||
@Deprecated
|
||||
@Override
|
||||
public float getPlayerRelativeBlockHardness(IBlockState state, EntityPlayer player, World worldIn, BlockPos pos) {
|
||||
return UBlocks.cloud.getPlayerRelativeBlockHardness(state, player, worldIn, pos);
|
||||
return modelBlock.getPlayerRelativeBlockHardness(state, player, worldIn, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEntityDestroy(IBlockState state, IBlockAccess world, BlockPos pos, Entity entity) {
|
||||
return modelBlock.canEntityDestroy(state, world, pos, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTranslationKey(int meta) {
|
||||
return super.getTranslationKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IProperty<Variant> getVariantProperty() {
|
||||
return VARIANT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CloudType getCloudMaterialType(IBlockState blockState) {
|
||||
return modelBlock.getCloudMaterialType(blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Comparable<Variant> getTypeForItem(ItemStack stack) {
|
||||
return Variant.DEFAULT;
|
||||
}
|
||||
|
||||
public static class Single<T extends Block & ICloudBlock> extends BlockCloudSlab<T> {
|
||||
|
||||
public final Double<T> doubleSlab;
|
||||
|
||||
public Single(T modelBlock, Material material, String domain, String name) {
|
||||
super(modelBlock, null, material, domain, name);
|
||||
|
||||
doubleSlab = new Double<>(this, domain, "double_" + name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDouble() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean doesSideBlockRendering(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing face) {
|
||||
|
||||
IBlockState beside = world.getBlockState(pos.offset(face));
|
||||
|
||||
if (beside.getBlock() instanceof ICloudBlock) {
|
||||
ICloudBlock cloud = ((ICloudBlock)beside.getBlock());
|
||||
|
||||
if (cloud.getCloudMaterialType(beside) == getCloudMaterialType(state)) {
|
||||
|
||||
EnumBlockHalf half = state.getValue(HALF);
|
||||
|
||||
if (beside.getBlock() instanceof BlockCloudStairs) {
|
||||
return beside.getValue(BlockStairs.HALF).ordinal() == state.getValue(HALF).ordinal()
|
||||
&& beside.getValue(BlockStairs.FACING) == face;
|
||||
}
|
||||
|
||||
if (face == EnumFacing.DOWN) {
|
||||
return half == EnumBlockHalf.BOTTOM;
|
||||
}
|
||||
|
||||
if (face == EnumFacing.UP) {
|
||||
return half == EnumBlockHalf.TOP;
|
||||
}
|
||||
|
||||
if (beside.getBlock() == this) {
|
||||
return beside.getValue(HALF) == state.getValue(HALF);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
return getDefaultState()
|
||||
.withProperty(VARIANT, Variant.DEFAULT)
|
||||
.withProperty(HALF, (meta & 8) == 0 ? BlockSlab.EnumBlockHalf.BOTTOM : BlockSlab.EnumBlockHalf.TOP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
int i = 0;
|
||||
|
||||
if (state.getValue(HALF) == BlockSlab.EnumBlockHalf.TOP) {
|
||||
i |= 8;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, HALF, VARIANT);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Double<T extends Block & ICloudBlock> extends BlockCloudSlab<T> {
|
||||
|
||||
public final Single<T> singleSlab;
|
||||
|
||||
public Double(Single<T> single, String domain, String name) {
|
||||
super(single.modelBlock, single, single.material, domain, name);
|
||||
|
||||
this.singleSlab = single;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDouble() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -133,111 +254,44 @@ public class BlockCloudSlab extends BlockSlab implements ICloudBlock {
|
|||
ICloudBlock cloud = ((ICloudBlock)beside.getBlock());
|
||||
|
||||
if (cloud.getCloudMaterialType(beside) == getCloudMaterialType(state)) {
|
||||
if (isDouble) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (face == EnumFacing.UP || face == EnumFacing.DOWN) {
|
||||
return (state.getValue(HALF) == EnumBlockHalf.TOP) && (face == EnumFacing.UP);
|
||||
}
|
||||
|
||||
if (beside.getBlock() == this) {
|
||||
return beside.getValue(HALF) == state.getValue(HALF);
|
||||
} else {
|
||||
if (beside.getBlock() instanceof BlockCloudStairs) {
|
||||
return beside.getValue(BlockStairs.HALF).ordinal() == state.getValue(HALF).ordinal()
|
||||
&& beside.getValue(BlockStairs.FACING) == face;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEntityDestroy(IBlockState state, IBlockAccess world, BlockPos pos, Entity entity) {
|
||||
return UBlocks.cloud.canEntityDestroy(state, world, pos, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
|
||||
return Item.getItemFromBlock(UBlocks.cloud_slab);
|
||||
return Item.getItemFromBlock(singleSlab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
|
||||
return new ItemStack(Item.getItemFromBlock(UBlocks.cloud_slab), 2, getMetaFromState(state));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTranslationKey(int meta) {
|
||||
return super.getTranslationKey() + "." + CloudType.byMetadata(meta).getTranslationKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IProperty<CloudType> getVariantProperty() {
|
||||
return VARIANT;
|
||||
}
|
||||
|
||||
public Object getVariant(ItemStack stack) {
|
||||
return CloudType.byMetadata(stack.getMetadata() & 7);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
|
||||
for (CloudType i : CloudType.values()) {
|
||||
list.add(new ItemStack(this, 1, i.getMetadata()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CloudType getCloudMaterialType(IBlockState blockState) {
|
||||
return (CloudType)blockState.getValue(VARIANT);
|
||||
public ItemStack getItem(World world, BlockPos pos, IBlockState state) {
|
||||
return new ItemStack(getItemDropped(state, world.rand, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
IBlockState state = getDefaultState().withProperty(VARIANT, CloudType.byMetadata(meta & 7));
|
||||
if (!isDouble()) {
|
||||
state = state.withProperty(HALF, (meta & 8) == 0 ? BlockSlab.EnumBlockHalf.BOTTOM : BlockSlab.EnumBlockHalf.TOP);
|
||||
}
|
||||
return state;
|
||||
return getDefaultState().withProperty(VARIANT, Variant.DEFAULT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the BlockState into the correct metadata value
|
||||
*/
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
byte mask = 0;
|
||||
int result = mask | getCloudMaterialType(state).getMetadata();
|
||||
if (!isDouble() && state.getValue(HALF) == BlockSlab.EnumBlockHalf.TOP) {
|
||||
result |= 8;
|
||||
}
|
||||
return result;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, isDouble() ?
|
||||
new IProperty[] {VARIANT}
|
||||
: new IProperty[] {HALF, VARIANT});
|
||||
return new BlockStateContainer(this, VARIANT);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(IBlockState state) {
|
||||
return getCloudMaterialType(state).getMetadata();
|
||||
}
|
||||
private static enum Variant implements IStringSerializable {
|
||||
DEFAULT;
|
||||
|
||||
@Override
|
||||
public boolean isDouble() {
|
||||
return isDouble;
|
||||
public String getName() {
|
||||
return "normal";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Comparable<CloudType> getTypeForItem(ItemStack stack) {
|
||||
return CloudType.byMetadata(stack.getMetadata() & 7);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -441,7 +441,7 @@ public class EntityCloud extends EntityFlying implements IAnimals, IInAnimate {
|
|||
if (type == 2) {
|
||||
if (!isBurning()) {
|
||||
for (int i = 0; i < 50 * getCloudSize(); i++) {
|
||||
Particles.instance().getEntityEmitter().emitDiggingParticles(this, UBlocks.cloud.getDefaultState());
|
||||
Particles.instance().getEntityEmitter().emitDiggingParticles(this, UBlocks.normal_cloud.getDefaultState());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -465,7 +465,7 @@ public class EntityCloud extends EntityFlying implements IAnimals, IInAnimate {
|
|||
|
||||
public void pomf() {
|
||||
for (int i = 0; i < 50 * getCloudSize(); i++) {
|
||||
Particles.instance().getEntityEmitter().emitDiggingParticles(this, UBlocks.cloud.getDefaultState());
|
||||
Particles.instance().getEntityEmitter().emitDiggingParticles(this, UBlocks.normal_cloud.getDefaultState());
|
||||
}
|
||||
|
||||
playHurtSound(DamageSource.GENERIC);
|
||||
|
@ -537,7 +537,7 @@ public class EntityCloud extends EntityFlying implements IAnimals, IInAnimate {
|
|||
if (stat || canFly) {
|
||||
if (!isBurning()) {
|
||||
for (int i = 0; i < 50 * getCloudSize(); i++) {
|
||||
Particles.instance().getEntityEmitter().emitDiggingParticles(this, UBlocks.cloud.getDefaultState());
|
||||
Particles.instance().getEntityEmitter().emitDiggingParticles(this, UBlocks.normal_cloud.getDefaultState());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package com.minelittlepony.unicopia.init;
|
||||
|
||||
import com.minelittlepony.unicopia.CloudType;
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
import com.minelittlepony.unicopia.block.BlockAlfalfa;
|
||||
import com.minelittlepony.unicopia.block.BlockFruitLeaves;
|
||||
import com.minelittlepony.unicopia.block.BlockGlowingGem;
|
||||
import com.minelittlepony.unicopia.block.BlockCloud;
|
||||
import com.minelittlepony.unicopia.block.BlockCloudAnvil;
|
||||
import com.minelittlepony.unicopia.block.BlockCloudBanister;
|
||||
import com.minelittlepony.unicopia.block.BlockCloudSlab;
|
||||
|
@ -17,6 +17,7 @@ import com.minelittlepony.unicopia.item.ItemApple;
|
|||
import com.minelittlepony.unicopia.block.BlockCloudDoor;
|
||||
import com.minelittlepony.unicopia.block.BlockCloudFarm;
|
||||
import com.minelittlepony.unicopia.block.BlockCloudFence;
|
||||
import com.minelittlepony.unicopia.block.BlockCloud;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
@ -33,12 +34,15 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
|
||||
public class UBlocks {
|
||||
public static final BlockCloud cloud = new BlockCloud(UMaterials.cloud, Unicopia.MODID, "cloud_block");
|
||||
public static final BlockCloud normal_cloud = new BlockCloud(UMaterials.cloud, CloudType.NORMAL, Unicopia.MODID, "cloud_block");
|
||||
public static final BlockCloud enchanted_cloud = new BlockCloud(UMaterials.cloud, CloudType.ENCHANTED, Unicopia.MODID, "enchanted_cloud_block");
|
||||
public static final BlockCloud packed_cloud = new BlockCloud(UMaterials.cloud, CloudType.PACKED, Unicopia.MODID, "packed_cloud_block");
|
||||
|
||||
public static final BlockCloudStairs cloud_stairs = new BlockCloudStairs(UBlocks.cloud.getDefaultState(), Unicopia.MODID, "cloud_stairs");
|
||||
public static final BlockCloudStairs cloud_stairs = new BlockCloudStairs(normal_cloud.getDefaultState(), Unicopia.MODID, "cloud_stairs");
|
||||
|
||||
public static final BlockCloudSlab cloud_double_slab = new BlockCloudSlab(true, UMaterials.cloud, Unicopia.MODID, "cloud_double_slab");
|
||||
public static final BlockCloudSlab cloud_slab = new BlockCloudSlab(false, UMaterials.cloud, Unicopia.MODID, "cloud_slab");
|
||||
public static final BlockCloudSlab.Single<?> cloud_slab = new BlockCloudSlab.Single<>(normal_cloud, UMaterials.cloud, Unicopia.MODID, "cloud_slab");
|
||||
public static final BlockCloudSlab.Single<?> enchanted_cloud_slab = new BlockCloudSlab.Single<>(enchanted_cloud, UMaterials.cloud, Unicopia.MODID, "enchanted_cloud_slab");
|
||||
public static final BlockCloudSlab.Single<?> packed_cloud_slab = new BlockCloudSlab.Single<>(enchanted_cloud, UMaterials.cloud, Unicopia.MODID, "packed_cloud_slab");
|
||||
|
||||
public static final BlockCloudDoor mist_door = new BlockCloudDoor(UMaterials.cloud, Unicopia.MODID, "mist_door");
|
||||
|
||||
|
@ -46,8 +50,8 @@ public class UBlocks {
|
|||
|
||||
public static final BlockCloudAnvil anvil = new BlockCloudAnvil(Unicopia.MODID, "anvil");
|
||||
|
||||
public static final BlockCloudFence cloud_fence = new BlockCloudFence(Unicopia.MODID, "cloud_fence");
|
||||
public static final BlockCloudBanister cloud_banister = new BlockCloudBanister(Unicopia.MODID, "cloud_banister");
|
||||
public static final BlockCloudFence cloud_fence = new BlockCloudFence(UMaterials.cloud, CloudType.NORMAL, Unicopia.MODID, "cloud_fence");
|
||||
public static final BlockCloudBanister cloud_banister = new BlockCloudBanister(UMaterials.cloud, Unicopia.MODID, "cloud_banister");
|
||||
|
||||
public static final BlockAlfalfa alfalfa = new BlockAlfalfa(Unicopia.MODID, "alfalfa");
|
||||
|
||||
|
@ -66,7 +70,12 @@ public class UBlocks {
|
|||
.setUnharvestFruit(w -> new ItemStack(UItems.rotten_apple));
|
||||
|
||||
static void init(IForgeRegistry<Block> registry) {
|
||||
registry.registerAll(cloud, cloud_stairs, cloud_double_slab, cloud_slab, cloud_fence, cloud_banister,
|
||||
registry.registerAll(normal_cloud, enchanted_cloud, packed_cloud,
|
||||
cloud_stairs,
|
||||
cloud_slab, cloud_slab.doubleSlab,
|
||||
enchanted_cloud_slab, enchanted_cloud_slab.doubleSlab,
|
||||
packed_cloud_slab, packed_cloud_slab.doubleSlab,
|
||||
cloud_fence, cloud_banister,
|
||||
mist_door, anvil, cloud_farmland,
|
||||
sugar_block,
|
||||
alfalfa,
|
||||
|
|
|
@ -17,7 +17,6 @@ import com.minelittlepony.unicopia.item.ItemTomato;
|
|||
import com.minelittlepony.unicopia.item.ItemTomatoSeeds;
|
||||
import com.minelittlepony.unicopia.item.ItemZapApple;
|
||||
import com.minelittlepony.unicopia.item.UItemBlock;
|
||||
import com.minelittlepony.unicopia.item.UItemMultiTexture;
|
||||
import com.minelittlepony.unicopia.item.UItemDecoration;
|
||||
import com.minelittlepony.unicopia.item.UItemSlab;
|
||||
import com.minelittlepony.unicopia.spell.SpellRegistry;
|
||||
|
@ -44,7 +43,6 @@ import net.minecraftforge.registries.IForgeRegistry;
|
|||
|
||||
import static com.minelittlepony.unicopia.Predicates.*;
|
||||
|
||||
import com.minelittlepony.unicopia.CloudType;
|
||||
import com.minelittlepony.unicopia.UClient;
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
import com.minelittlepony.unicopia.edibles.BushToxicityDeterminent;
|
||||
|
@ -83,29 +81,28 @@ public class UItems {
|
|||
|
||||
public static final ItemCloud cloud_spawner = new ItemCloud(Unicopia.MODID, "cloud");
|
||||
|
||||
public static final Item cloud_block = new UItemMultiTexture(UBlocks.cloud, stack ->
|
||||
CloudType.byMetadata(stack.getMetadata()).getTranslationKey(), INTERACT_WITH_CLOUDS)
|
||||
.setRegistryName(Unicopia.MODID, "cloud_block");
|
||||
public static final Item cloud_block = new UItemBlock(UBlocks.normal_cloud, INTERACT_WITH_CLOUDS);
|
||||
public static final Item enchanted_cloud = new UItemBlock(UBlocks.enchanted_cloud, INTERACT_WITH_CLOUDS);
|
||||
public static final Item packed_cloud = new UItemBlock(UBlocks.packed_cloud, INTERACT_WITH_CLOUDS);
|
||||
|
||||
public static final Item cloud_stairs = new UItemBlock(UBlocks.cloud_stairs, Unicopia.MODID, "cloud_stairs", INTERACT_WITH_CLOUDS);
|
||||
public static final Item cloud_stairs = new UItemBlock(UBlocks.cloud_stairs, INTERACT_WITH_CLOUDS);
|
||||
|
||||
public static final Item cloud_farmland = new UItemBlock(UBlocks.cloud_farmland, Unicopia.MODID, "cloud_farmland", INTERACT_WITH_CLOUDS);
|
||||
public static final Item cloud_farmland = new UItemBlock(UBlocks.cloud_farmland, INTERACT_WITH_CLOUDS);
|
||||
|
||||
public static final Item cloud_fence = new UItemBlock(UBlocks.cloud_fence, Unicopia.MODID, "cloud_fence", INTERACT_WITH_CLOUDS);
|
||||
public static final Item cloud_banister = new UItemBlock(UBlocks.cloud_banister, Unicopia.MODID, "cloud_banister", INTERACT_WITH_CLOUDS);
|
||||
public static final Item cloud_fence = new UItemBlock(UBlocks.cloud_fence, INTERACT_WITH_CLOUDS);
|
||||
public static final Item cloud_banister = new UItemBlock(UBlocks.cloud_banister, INTERACT_WITH_CLOUDS);
|
||||
|
||||
public static final Item anvil = new UItemBlock(UBlocks.anvil, Unicopia.MODID, "anvil", INTERACT_WITH_CLOUDS)
|
||||
.setTranslationKey("cloud_anvil");
|
||||
public static final Item anvil = new UItemBlock(UBlocks.anvil, INTERACT_WITH_CLOUDS).setTranslationKey("cloud_anvil");
|
||||
|
||||
public static final Item mist_door = new ItemDoor(UBlocks.mist_door)
|
||||
.setTranslationKey("mist_door")
|
||||
.setRegistryName(Unicopia.MODID, "mist_door");
|
||||
|
||||
public static final Item sugar_block = new UItemDecoration(UBlocks.sugar_block, Unicopia.MODID, "sugar_block");
|
||||
public static final Item sugar_block = new UItemDecoration(UBlocks.sugar_block);
|
||||
|
||||
public static final Item cloud_slab = new UItemSlab(UBlocks.cloud_slab, UBlocks.cloud_double_slab, INTERACT_WITH_CLOUDS)
|
||||
.setTranslationKey("cloud_slab")
|
||||
.setRegistryName(Unicopia.MODID, "cloud_slab");
|
||||
public static final Item cloud_slab = new UItemSlab(UBlocks.cloud_slab, UBlocks.cloud_slab.doubleSlab, INTERACT_WITH_CLOUDS);
|
||||
public static final Item enchanted_cloud_slab = new UItemSlab(UBlocks.enchanted_cloud_slab, UBlocks.enchanted_cloud_slab.doubleSlab, INTERACT_WITH_CLOUDS);
|
||||
public static final Item packed_cloud_slab = new UItemSlab(UBlocks.packed_cloud_slab, UBlocks.packed_cloud_slab.doubleSlab, INTERACT_WITH_CLOUDS);
|
||||
|
||||
public static final ItemSpell spell = new ItemSpell(Unicopia.MODID, "gem");
|
||||
public static final ItemSpell curse = new ItemCurse(Unicopia.MODID, "corrupted_gem");
|
||||
|
@ -139,7 +136,7 @@ public class UItems {
|
|||
|
||||
public static final Item apple_seeds = new UItemDecoration(UBlocks.apple_tree, Unicopia.MODID, "apple_seeds");
|
||||
|
||||
public static final Item apple_leaves = new ItemFruitLeaves(UBlocks.apple_leaves, Unicopia.MODID, "apple_leaves");
|
||||
public static final Item apple_leaves = new ItemFruitLeaves(UBlocks.apple_leaves);
|
||||
|
||||
public static final Item double_plant = new UItemFoodDelegate(Blocks.DOUBLE_PLANT, stack ->
|
||||
BlockDoublePlant.EnumPlantType.byMetadata(stack.getMetadata()).getTranslationKey()
|
||||
|
@ -210,8 +207,10 @@ public class UItems {
|
|||
|
||||
registry.registerAll(
|
||||
green_apple, sweet_apple, sour_apple,
|
||||
cloud_spawner, dew_drop, cloud_matter, cloud_block,
|
||||
cloud_stairs, cloud_slab, cloud_fence, cloud_banister,
|
||||
cloud_spawner, dew_drop, cloud_matter, cloud_block, enchanted_cloud, packed_cloud,
|
||||
cloud_stairs,
|
||||
cloud_slab, enchanted_cloud_slab, packed_cloud_slab,
|
||||
cloud_fence, cloud_banister,
|
||||
cloud_farmland, mist_door, anvil,
|
||||
|
||||
bag_of_holding, spell, curse, spellbook, mug, enchanted_torch,
|
||||
|
@ -229,8 +228,6 @@ public class UItems {
|
|||
apple_cider, juice, burned_juice);
|
||||
|
||||
if (UClient.isClientSide()) {
|
||||
ItemModels.registerAllVariants(cloud_slab, CloudType.getVariants("_cloud_slab"));
|
||||
ItemModels.registerAllVariants(cloud_block, CloudType.getVariants("_cloud_block"));
|
||||
ItemModels.registerAll(
|
||||
cloud_spawner,
|
||||
|
||||
|
@ -241,7 +238,10 @@ public class UItems {
|
|||
|
||||
tomato, cloudsdale_tomato,
|
||||
|
||||
cloud_spawner, cloud_matter, cloud_stairs, cloud_fence, cloud_banister,
|
||||
cloud_spawner, cloud_matter, cloud_block, enchanted_cloud, packed_cloud,
|
||||
cloud_stairs,
|
||||
cloud_slab, enchanted_cloud_slab, packed_cloud_slab,
|
||||
cloud_fence, cloud_banister,
|
||||
cloud_farmland, mist_door, anvil,
|
||||
|
||||
bag_of_holding, spell, curse, spellbook, mug, enchanted_torch,
|
||||
|
|
|
@ -4,8 +4,8 @@ import net.minecraft.block.Block;
|
|||
|
||||
public class ItemFruitLeaves extends UItemDecoration {
|
||||
|
||||
public ItemFruitLeaves(Block block, String domain, String name) {
|
||||
super(block, domain, name);
|
||||
public ItemFruitLeaves(Block block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,6 +6,7 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
@ -13,6 +14,19 @@ public class UItemBlock extends UItemDecoration {
|
|||
|
||||
private final Predicate<EntityPlayer> abilityTest;
|
||||
|
||||
public UItemBlock(Block block, Predicate<EntityPlayer> abilityTest) {
|
||||
super(block);
|
||||
|
||||
this.abilityTest = abilityTest;
|
||||
}
|
||||
|
||||
public UItemBlock(Block block, ResourceLocation res, Predicate<EntityPlayer> abilityTest) {
|
||||
super(block, res);
|
||||
|
||||
this.abilityTest = abilityTest;
|
||||
}
|
||||
|
||||
|
||||
public UItemBlock(Block block, String domain, String name, Predicate<EntityPlayer> abilityTest) {
|
||||
super(block, domain, name);
|
||||
|
||||
|
|
|
@ -2,14 +2,23 @@ package com.minelittlepony.unicopia.item;
|
|||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class UItemDecoration extends ItemBlock {
|
||||
|
||||
public UItemDecoration(Block block) {
|
||||
this(block, block.getRegistryName());
|
||||
}
|
||||
|
||||
public UItemDecoration(Block block, String domain, String name) {
|
||||
this(block, new ResourceLocation(domain, name));
|
||||
}
|
||||
|
||||
public UItemDecoration(Block block, ResourceLocation res) {
|
||||
super(block);
|
||||
|
||||
setTranslationKey(name);
|
||||
setRegistryName(domain, name);
|
||||
setTranslationKey(res.getPath());
|
||||
setRegistryName(res);
|
||||
setCreativeTab(block.getCreativeTab());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ public class UItemMultiTexture extends ItemMultiTexture {
|
|||
|
||||
public UItemMultiTexture(Block block, ItemMultiTexture.Mapper mapper, Predicate<EntityPlayer> abilityTest) {
|
||||
super(block, block, mapper);
|
||||
this.setRegistryName(block.getRegistryName());
|
||||
|
||||
this.abilityTest = abilityTest;
|
||||
}
|
||||
|
|
|
@ -16,16 +16,19 @@ public class UItemSlab extends ItemSlab {
|
|||
|
||||
public UItemSlab(BlockSlab singleSlab, BlockSlab doubleSlab, Predicate<EntityPlayer> abilityTest) {
|
||||
super(singleSlab, singleSlab, doubleSlab);
|
||||
|
||||
this.abilityTest = abilityTest;
|
||||
|
||||
setHasSubtypes(false);
|
||||
setRegistryName(singleSlab.getRegistryName());
|
||||
setTranslationKey(singleSlab.getRegistryName().getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack) {
|
||||
public boolean canPlaceBlockOnSide(World world, BlockPos origin, EnumFacing side, EntityPlayer player, ItemStack stack) {
|
||||
if (!(player.capabilities.isCreativeMode || abilityTest.test(player))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return super.canPlaceBlockOnSide(worldIn, pos, side, player, stack);
|
||||
return super.canPlaceBlockOnSide(world, origin, side, player, stack);
|
||||
}
|
||||
}
|
||||
|
|
101
src/main/java/com/minelittlepony/util/fixers/BlockFixer.java
Normal file
101
src/main/java/com/minelittlepony/util/fixers/BlockFixer.java
Normal file
|
@ -0,0 +1,101 @@
|
|||
package com.minelittlepony.util.fixers;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.datafix.IFixableData;
|
||||
import net.minecraft.world.chunk.NibbleArray;
|
||||
|
||||
public abstract class BlockFixer implements IFixableData {
|
||||
|
||||
protected NBTTagCompound fixChunk(NBTTagCompound chunk) {
|
||||
byte[] blocks = chunk.getByteArray("Blocks");
|
||||
|
||||
NibbleArray data = new NibbleArray(chunk.getByteArray("Data"));
|
||||
NibbleArray add = chunk.hasKey("Add", 7) ? new NibbleArray(chunk.getByteArray("Add")) : null;
|
||||
|
||||
boolean altered = false;
|
||||
|
||||
for (int i = 0; i < 4096; i++) {
|
||||
int xPos = i & 15;
|
||||
int yPos = i >> 8 & 15;
|
||||
int zPos = i >> 4 & 15;
|
||||
|
||||
int extendedBlockId = (add == null ? 0 : add.get(xPos, yPos, zPos));
|
||||
int baseBlockId = blocks[i] & 255;
|
||||
|
||||
|
||||
int blockid = (extendedBlockId << 8) | baseBlockId;
|
||||
int metadata = data.get(xPos, yPos, zPos);
|
||||
|
||||
int blockStateId = (blockid << 4) | metadata;
|
||||
|
||||
Block block = Block.getBlockById(blockid);
|
||||
|
||||
|
||||
if (block != null) {
|
||||
IBlockState state = fixBlockState(blockid, metadata);
|
||||
|
||||
if (state != null) {
|
||||
@SuppressWarnings("deprecation")
|
||||
int newBlockStateId = Block.BLOCK_STATE_IDS.get(state);
|
||||
|
||||
if (newBlockStateId != blockStateId) {
|
||||
metadata = newBlockStateId & 15;
|
||||
blockid = newBlockStateId >> 4;
|
||||
extendedBlockId = blockid >> 8;
|
||||
baseBlockId = blockid & 255;
|
||||
|
||||
if (extendedBlockId != 0) {
|
||||
if (add == null) {
|
||||
add = new NibbleArray(new byte[data.getData().length]);
|
||||
}
|
||||
|
||||
add.set(xPos, yPos, zPos, extendedBlockId);
|
||||
}
|
||||
|
||||
data.set(xPos, yPos, zPos, metadata);
|
||||
blocks[i] = (byte)blockid;
|
||||
|
||||
altered = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (altered) {
|
||||
if (add != null) {
|
||||
chunk.setByteArray("Add", add.getData());
|
||||
}
|
||||
chunk.setByteArray("Blocks", blocks);
|
||||
chunk.setByteArray("Data", data.getData());
|
||||
}
|
||||
|
||||
return chunk;
|
||||
}
|
||||
|
||||
protected abstract IBlockState fixBlockState(int id, int metadata);
|
||||
|
||||
@Override
|
||||
public NBTTagCompound fixTagCompound(NBTTagCompound compound) {
|
||||
|
||||
if (compound.hasKey("Level", 10)) {
|
||||
NBTTagCompound level = compound.getCompoundTag("Level");
|
||||
|
||||
if (level.hasKey("Sections", 9)) {
|
||||
NBTTagList sections = level.getTagList("Sections", 10);
|
||||
|
||||
for (int i = 0; i < sections.tagCount(); i++) {
|
||||
NBTTagCompound chunk = sections.getCompoundTagAt(i);
|
||||
|
||||
if (chunk.hasKey("Blocks", 7) && chunk.hasKey("Data", 7)) {
|
||||
sections.set(i, fixChunk(chunk));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
}
|
|
@ -1,7 +1,5 @@
|
|||
{
|
||||
"variants": {
|
||||
"variant=normal": { "model": "unicopia:normal_cloud_block" },
|
||||
"variant=packed": { "model": "unicopia:packed_cloud_block" },
|
||||
"variant=enchanted": { "model": "unicopia:enchanted_cloud_block" }
|
||||
"normal": { "model": "unicopia:normal_cloud_block" }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
{
|
||||
"variants": {
|
||||
"half=bottom,variant=normal": { "model": "unicopia:normal_cloud_block" },
|
||||
"half=bottom,variant=packed": { "model": "unicopia:packed_cloud_block" },
|
||||
"half=bottom,variant=enchanted": { "model": "unicopia:enchanted_cloud_block" },
|
||||
|
||||
"half=top,variant=normal": { "model": "unicopia:normal_cloud_block" },
|
||||
"half=top,variant=packed": { "model": "unicopia:packed_cloud_block" },
|
||||
"half=top,variant=enchanted": { "model": "unicopia:enchanted_cloud_block" }
|
||||
}
|
||||
}
|
|
@ -1,10 +1,6 @@
|
|||
{
|
||||
"variants": {
|
||||
"half=bottom,variant=normal": { "model": "unicopia:half_slab_normal_cloud" },
|
||||
"half=top,variant=normal": { "model": "unicopia:upper_slab_normal_cloud" },
|
||||
"half=bottom,variant=packed": { "model": "unicopia:half_slab_packed_cloud" },
|
||||
"half=top,variant=packed": { "model": "unicopia:upper_slab_packed_cloud" },
|
||||
"half=bottom,variant=enchanted": { "model": "unicopia:half_slab_enchanted_cloud" },
|
||||
"half=top,variant=enchanted": { "model": "unicopia:upper_slab_enchanted_cloud" }
|
||||
"half=top,variant=normal": { "model": "unicopia:upper_slab_normal_cloud" }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"variants": {
|
||||
"variant=normal": { "model": "unicopia:normal_cloud_block" }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"variants": {
|
||||
"variant=normal": { "model": "unicopia:enchanted_cloud_block" }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"variants": {
|
||||
"variant=normal": { "model": "unicopia:packed_cloud_block" }
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"variants": {
|
||||
"half=bottom": { "model": "unicopia:half_slab_enchanted_cloud" },
|
||||
"half=top": { "model": "unicopia:upper_slab_enchanted_cloud" }
|
||||
"half=bottom,variant=normal": { "model": "unicopia:half_slab_enchanted_cloud" },
|
||||
"half=top,variant=normal": { "model": "unicopia:upper_slab_enchanted_cloud" }
|
||||
}
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": { "model": "unicopia:normal_cloud_block" }
|
||||
}
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"variants": {
|
||||
"half=bottom": { "model": "unicopia:half_slab_normal_cloud" },
|
||||
"half=top": { "model": "unicopia:upper_slab_normal_cloud" }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": { "model": "unicopia:enchanted_cloud_block" }
|
||||
}
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": { "model": "unicopia:packed_cloud_block" }
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"variants": {
|
||||
"half=bottom": { "model": "unicopia:half_slab_packed_cloud" },
|
||||
"half=top": { "model": "unicopia:upper_slab_packed_cloud" }
|
||||
"half=bottom,variant=normal": { "model": "unicopia:half_slab_packed_cloud" },
|
||||
"half=top,variant=normal": { "model": "unicopia:upper_slab_packed_cloud" }
|
||||
}
|
||||
}
|
|
@ -1,10 +1,13 @@
|
|||
tile.cloud_block.normal.name=Block of Cloud
|
||||
tile.cloud_block.packed.name=Dense Cloud
|
||||
tile.cloud_block.enchanted.name=Enchanted Cloud
|
||||
tile.normal_cloud_block.name=Block of Cloud
|
||||
tile.packed_cloud_block.name=Dense Cloud
|
||||
tile.enchanted_cloud_block.name=Enchanted Cloud
|
||||
|
||||
tile.cloud_slab.normal.name=Cloud Slab
|
||||
tile.cloud_slab.packed.name=Dense Cloud Slab
|
||||
tile.cloud_slab.enchanted.name=Enchanted Cloud Slab
|
||||
tile.normal_cloud_slab.name=Cloud Slab
|
||||
tile.double_normal_cloud_slab.name=Double Cloud Slab
|
||||
tile.packed_cloud_slab.name=Dense Cloud Slab
|
||||
tile.packed_normal_cloud_slab.name=Double Dense Cloud Slab
|
||||
tile.enchanted_cloud_slab.name=Enchanted Cloud Slab
|
||||
tile.double_enchanted_cloud_slab.name=Double Enchanted Cloud Slab
|
||||
|
||||
tile.cloud_stairs.name=Cloud Stairs
|
||||
tile.cloud_fence.name=Cloud Fence
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
],
|
||||
"key": {
|
||||
"#": [
|
||||
{ "item": "unicopia:cloud_block", "data": 0 }
|
||||
{ "item": "unicopia:cloud_block" }
|
||||
]
|
||||
},
|
||||
"result": { "item": "unicopia:anvil", "data": 0, "count": 1 }
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
],
|
||||
"key": {
|
||||
"B": [
|
||||
{ "item": "unicopia:cloud_block", "data": 0 }
|
||||
{ "item": "unicopia:cloud_block" }
|
||||
]
|
||||
},
|
||||
"result": { "item": "unicopia:cloud_fence", "count": 3 }
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
],
|
||||
"key": {
|
||||
"#": [
|
||||
{ "item": "unicopia:cloud_block", "data": 0 }
|
||||
{ "item": "unicopia:cloud_block" }
|
||||
]
|
||||
},
|
||||
"result": { "item": "unicopia:cloud_stairs", "count": 4 }
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
],
|
||||
"key": {
|
||||
"#": [
|
||||
{ "item": "unicopia:cloud_block", "data": 0 }
|
||||
{ "item": "unicopia:cloud_block" }
|
||||
],
|
||||
"*": [
|
||||
{ "item": "unicopia:cloud_matter" }
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
],
|
||||
"key": {
|
||||
"#": [
|
||||
{ "item": "unicopia:cloud_block", "data": 0 }
|
||||
{ "item": "unicopia:cloud_block" }
|
||||
],
|
||||
"$": [
|
||||
{ "item": "unicopia:dew_drop" }
|
||||
|
@ -47,5 +47,5 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"result": { "item": "unicopia:cloud_block", "data": 2, "count": 5 }
|
||||
"result": { "item": "unicopia:enchanted_cloud_block", "count": 5 }
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
],
|
||||
"key": {
|
||||
"#": [
|
||||
{ "item": "unicopia:cloud_block", "data": 2 }
|
||||
{ "item": "unicopia:enchanted_cloud_block" }
|
||||
]
|
||||
},
|
||||
"result": { "item": "unicopia:cloud_slab", "data": 2, "count": 6 }
|
||||
"result": { "item": "unicopia:enchanted_cloud_slab", "count": 6 }
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
],
|
||||
"key": {
|
||||
"#": [
|
||||
{ "item": "unicopia:cloud_block", "data": 0 }
|
||||
{ "item": "unicopia:cloud_block" }
|
||||
]
|
||||
},
|
||||
"result": { "item": "unicopia:mist_door", "data": 0, "count": 1 }
|
||||
|
|
|
@ -10,5 +10,5 @@
|
|||
{ "item": "unicopia:cloud_matter" }
|
||||
]
|
||||
},
|
||||
"result": { "item": "unicopia:cloud_block", "data": 0, "count": 1 }
|
||||
"result": { "item": "unicopia:cloud_block", "count": 1 }
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
],
|
||||
"key": {
|
||||
"#": [
|
||||
{ "item": "unicopia:cloud_block", "data": 0 }
|
||||
{ "item": "unicopia:cloud_block" }
|
||||
]
|
||||
},
|
||||
"result": { "item": "unicopia:cloud_slab", "data": 0, "count": 6 }
|
||||
"result": { "item": "unicopia:cloud_slab", "count": 6 }
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
],
|
||||
"key": {
|
||||
"#": [
|
||||
{ "item": "unicopia:cloud_block", "data": 0 }
|
||||
{ "item": "unicopia:cloud_block" }
|
||||
]
|
||||
},
|
||||
"result": { "item": "unicopia:cloud_block", "data": 1, "count": 1 }
|
||||
"result": { "item": "unicopia:packed_cloud_block", "count": 1 }
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
],
|
||||
"key": {
|
||||
"#": [
|
||||
{ "item": "unicopia:cloud_block", "data": 1 }
|
||||
{ "item": "unicopia:packed_cloud_block" }
|
||||
]
|
||||
},
|
||||
"result": { "item": "unicopia:cloud_slab", "data": 1, "count": 6 }
|
||||
"result": { "item": "unicopia:packed_cloud_slab", "count": 6 }
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
],
|
||||
"key": {
|
||||
"#": [
|
||||
{ "item": "unicopia:cloud_block", "data": 0 }
|
||||
{ "item": "unicopia:cloud_block" }
|
||||
],
|
||||
"*": [
|
||||
{ "item": "unicopia:cloud_matter" }
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
],
|
||||
"key": {
|
||||
"#": [
|
||||
{ "item": "unicopia:cloud_block", "data": 0 }
|
||||
{ "item": "unicopia:cloud_block" }
|
||||
]
|
||||
},
|
||||
"result": { "item": "unicopia:cloud", "data": 2, "count": 1 }
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue