Skip to content

Commit

Permalink
Implemented drawbridge - basic mode
Browse files Browse the repository at this point in the history
  • Loading branch information
fuj1n committed Sep 21, 2019
1 parent 17fac09 commit 21e3d8f
Show file tree
Hide file tree
Showing 10 changed files with 422 additions and 50 deletions.
Expand Up @@ -154,9 +154,4 @@ public BlockItem registerBlockItem(IForgeRegistry<Item> registry, Block block, I
BlockItem itemBlock = new MechworksBlockItem(block, new Item.Properties().group(group));
return this.register(registry, itemBlock, block.getRegistryName());
}

public <T extends TileEntity> TileEntityType<T> registerTE(IForgeRegistry<TileEntityType<?>> registry, Supplier<T> constructor, String name, Block... validBlocks) {
TileEntityType<T> type = TileEntityType.Builder.create(constructor, validBlocks).build(null);
return this.register(registry, type, name);
}
}
Expand Up @@ -16,6 +16,7 @@
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.common.util.Constants;
import slimeknights.tmechworks.common.MechworksConfig;
import slimeknights.tmechworks.common.blocks.tileentity.DrawbridgeTileEntity;
import slimeknights.tmechworks.common.items.MechworksBlockItem;

Expand Down Expand Up @@ -68,16 +69,17 @@ public void setDefaultNBT(CompoundNBT nbt, CompoundNBT blockState) {

blockState.putInt("PlaceAngle", 1);
blockState.putInt("PlaceDirectionRaw", 2);
blockState.putInt("InventorySize", 1);
blockState.putInt("InventorySize", DrawbridgeTileEntity.UPGRADES_SIZE + 1);
nbt.putBoolean("drawAdvanced", false);
}

@Override
public void onBlockItemConstruct(MechworksBlockItem item) {
item.addPropertyOverride(new ResourceLocation("advanced"), (stack, world, entity) -> {
boolean advanced = false;

if(stack.hasTag() && stack.getTag().contains("renderAdvanced", Constants.NBT.TAG_BYTE))
advanced = stack.getTag().getBoolean("renderAdvanced");
if(stack.hasTag() && stack.getTag().contains("drawAdvanced", Constants.NBT.TAG_BYTE))
advanced = stack.getTag().getBoolean("drawAdvanced");

return advanced ? 1F : 0F;
});
Expand Down
Expand Up @@ -244,7 +244,6 @@ public boolean canHarvestBlock(BlockState state, IBlockReader world, BlockPos po
}

public void setDefaultNBT(CompoundNBT nbt, CompoundNBT blockState){
blockState.put("Items", new ListNBT());
blockState.putInt("InventorySize", 0);
}
}

0 comments on commit 21e3d8f

Please sign in to comment.