diff --git a/build.properties b/build.properties index 4e91535cc01..edf78d43b9d 100644 --- a/build.properties +++ b/build.properties @@ -13,5 +13,5 @@ tinker_version=2.10.0.+ dynamic_tree_version=0.7.+ jei_version=4.8.5.147 c_b_version=14.0.162 -structurize_version=0.10.70-ALPHA +structurize_version=0.10.72-ALPHA diff --git a/src/main/java/com/minecolonies/coremod/MineColonies.java b/src/main/java/com/minecolonies/coremod/MineColonies.java index b03b694133d..dcd9b206b41 100644 --- a/src/main/java/com/minecolonies/coremod/MineColonies.java +++ b/src/main/java/com/minecolonies/coremod/MineColonies.java @@ -274,6 +274,8 @@ private static synchronized void initializeNetwork() getNetwork().registerMessage(SifterSettingsMessage.class, SifterSettingsMessage.class, ++id, Side.SERVER); getNetwork().registerMessage(HutRenameMessage.class, HutRenameMessage.class, ++id, Side.SERVER); getNetwork().registerMessage(BuildingHiringModeMessage.class, BuildingHiringModeMessage.class, ++id, Side.SERVER); + getNetwork().registerMessage(DecorationBuildRequestMessage.class, DecorationBuildRequestMessage.class, ++id, Side.SERVER); + getNetwork().registerMessage(DecorationControllUpdateMessage.class, DecorationControllUpdateMessage.class, ++id, Side.SERVER); //Client side only getNetwork().registerMessage(BlockParticleEffectMessage.class, BlockParticleEffectMessage.class, ++id, Side.CLIENT); diff --git a/src/main/java/com/minecolonies/coremod/blocks/AbstractBlockMinecoloniesDirectional.java b/src/main/java/com/minecolonies/coremod/blocks/AbstractBlockMinecoloniesHorizontal.java similarity index 81% rename from src/main/java/com/minecolonies/coremod/blocks/AbstractBlockMinecoloniesDirectional.java rename to src/main/java/com/minecolonies/coremod/blocks/AbstractBlockMinecoloniesHorizontal.java index c4be18498c1..33381e90a40 100644 --- a/src/main/java/com/minecolonies/coremod/blocks/AbstractBlockMinecoloniesDirectional.java +++ b/src/main/java/com/minecolonies/coremod/blocks/AbstractBlockMinecoloniesHorizontal.java @@ -9,9 +9,9 @@ import net.minecraft.item.ItemBlock; import net.minecraftforge.registries.IForgeRegistry; -public abstract class AbstractBlockMinecoloniesDirectional> extends BlockHorizontal implements IBlockMinecolonies +public abstract class AbstractBlockMinecoloniesHorizontal> extends BlockHorizontal implements IBlockMinecolonies { - public AbstractBlockMinecoloniesDirectional(final Material blockMaterialIn) + public AbstractBlockMinecoloniesHorizontal(final Material blockMaterialIn) { super(blockMaterialIn); } @@ -30,7 +30,6 @@ public B registerBlock(final IForgeRegistry registry) return (B) this; } - /** * Registery block at gameregistry. * diff --git a/src/main/java/com/minecolonies/coremod/blocks/BlockBarrel.java b/src/main/java/com/minecolonies/coremod/blocks/BlockBarrel.java index 962488fdbe2..895c11857fc 100644 --- a/src/main/java/com/minecolonies/coremod/blocks/BlockBarrel.java +++ b/src/main/java/com/minecolonies/coremod/blocks/BlockBarrel.java @@ -29,7 +29,7 @@ import static com.minecolonies.api.util.constant.Suppression.DEPRECATION; -public class BlockBarrel extends AbstractBlockMinecoloniesDirectional implements ITileEntityProvider +public class BlockBarrel extends AbstractBlockMinecoloniesHorizontal implements ITileEntityProvider { public static final PropertyEnum VARIANT = PropertyEnum.create("variant", BarrelType.class); diff --git a/src/main/java/com/minecolonies/coremod/blocks/BlockDecorationController.java b/src/main/java/com/minecolonies/coremod/blocks/BlockDecorationController.java new file mode 100644 index 00000000000..bf6adb5c6a5 --- /dev/null +++ b/src/main/java/com/minecolonies/coremod/blocks/BlockDecorationController.java @@ -0,0 +1,258 @@ +package com.minecolonies.coremod.blocks; + +import com.ldtteam.structurize.blocks.interfaces.IAnchorBlock; +import com.minecolonies.api.entity.ai.citizen.builder.IBuilderUndestroyable; +import com.minecolonies.api.util.constant.Constants; +import com.minecolonies.coremod.MineColonies; +import com.minecolonies.coremod.creativetab.ModCreativeTabs; +import com.minecolonies.coremod.tileentities.TileEntityDecorationController; +import net.minecraft.block.material.Material; +import net.minecraft.block.properties.PropertyBool; +import net.minecraft.block.state.BlockStateContainer; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.*; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import org.jetbrains.annotations.NotNull; + +import javax.annotation.Nullable; + +import static com.minecolonies.api.util.constant.Suppression.DEPRECATION; + +/** + * Creates a decoration placerholder block. + */ +public class BlockDecorationController extends AbstractBlockMinecoloniesHorizontal implements IBuilderUndestroyable, IAnchorBlock +{ + /** + * The hardness this block has. + */ + private static final float BLOCK_HARDNESS = 5F; + + /** + * This blocks name. + */ + private static final String BLOCK_NAME = "decorationcontroller"; + + /** + * The resistance this block has. + */ + private static final float RESISTANCE = 1F; + + /** + * If the block is mirrored. + */ + public static PropertyBool MIRROR = PropertyBool.create("mirror"); + + /** + * The bounding boxes. + */ + protected static final AxisAlignedBB AABB_NORTH = new AxisAlignedBB(0.4125D, 0.375D, 0.950D, 0.5875D, 0.625D, 1.0D); + protected static final AxisAlignedBB AABB_SOUTH = new AxisAlignedBB(0.4125D, 0.375D, 0.0D, 0.5875D, 0.625D, 0.050D); + protected static final AxisAlignedBB AABB_WEST = new AxisAlignedBB(0.950D, 0.375D, 0.4125D, 1.0D, 0.625D, 0.5875D); + protected static final AxisAlignedBB AABB_EAST = new AxisAlignedBB(0.0D, 0.375D, 0.4125D, 0.050D, 0.625D, 0.5875D); + + /** + * Constructor for the placerholder. + * + * @param blockMaterialIn the material. + */ + public BlockDecorationController(final Material blockMaterialIn) + { + super(blockMaterialIn); + this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(MIRROR, false)); + initBlock(); + } + + /** + * Initialize the block. + */ + private void initBlock() + { + setRegistryName(Constants.MOD_ID.toLowerCase() + ":" + BLOCK_NAME); + setTranslationKey(String.format("%s.%s", Constants.MOD_ID.toLowerCase(), BLOCK_NAME)); + setCreativeTab(ModCreativeTabs.MINECOLONIES); + setHardness(BLOCK_HARDNESS); + setResistance(RESISTANCE); + } + + /** + * @deprecated + */ + @Nullable + public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, @NotNull IBlockAccess worldIn, @NotNull BlockPos pos) + { + return NULL_AABB; + } + + /** + * @deprecated + */ + @NotNull + @Override + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) + { + EnumFacing enumfacing = state.getValue(FACING); + switch (enumfacing) + { + case EAST: + return AABB_EAST; + case WEST: + return AABB_WEST; + case SOUTH: + return AABB_SOUTH; + case NORTH: + default: + return AABB_NORTH; + } + } + + @Override + public boolean onBlockActivated( + final World worldIn, + final BlockPos pos, + final IBlockState state, + final EntityPlayer playerIn, + final EnumHand hand, + final EnumFacing facing, + final float hitX, + final float hitY, + final float hitZ) + { + if (worldIn.isRemote) + { + final TileEntity tileEntity = worldIn.getTileEntity(pos); + if (tileEntity instanceof TileEntityDecorationController) + { + MineColonies.proxy.openDecorationControllerWindow(pos); + } + } + return true; + } + + @Override + public boolean hasTileEntity(final IBlockState state) + { + return true; + } + + @NotNull + @Override + protected BlockStateContainer createBlockState() + { + return new BlockStateContainer(this, FACING, MIRROR); + } + + @Nullable + @Override + public TileEntity createTileEntity(@NotNull final World world, @NotNull final IBlockState state) + { + return new TileEntityDecorationController(); + } + + @Override + public int getMetaFromState(final IBlockState state) + { + return state.getValue(FACING).getHorizontalIndex() + (state.getValue(MIRROR) ? 4 : 0); + } + + @NotNull + @Override + public IBlockState getStateFromMeta(final int meta) + { + int theMeta = meta; + boolean mirrored = false; + if (meta > 3) + { + mirrored = true; + theMeta = meta - 4; + } + + return getDefaultState().withProperty(FACING, EnumFacing.byHorizontalIndex(theMeta)).withProperty(MIRROR, mirrored); + } + + @NotNull + @Override + public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) + { + if (facing.getAxis().isHorizontal()) + { + return super.getStateForPlacement(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer).withProperty(FACING, facing); + } + return super.getStateForPlacement(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer); + } + + /** + * @deprecated + */ + @NotNull + @Override + public IBlockState withRotation(@NotNull IBlockState state, Rotation rot) + { + return state.withProperty(FACING, rot.rotate(state.getValue(FACING))); + } + + /** + * @deprecated + */ + @NotNull + @Override + public IBlockState withMirror(@NotNull IBlockState state, Mirror mirrorIn) + { + return state.withProperty(MIRROR, mirrorIn != Mirror.NONE); + } + + /** + * @deprecated (Remove this as soon as minecraft offers anything better). + */ + @SuppressWarnings(DEPRECATION) + @Override + @Deprecated + public boolean isFullBlock(final IBlockState state) + { + return false; + } + + /** + * @deprecated (Remove this as soon as minecraft offers anything better). + */ + @SuppressWarnings(DEPRECATION) + @Override + @Deprecated + public boolean isFullCube(final IBlockState state) + { + return false; + } + + /** + * @deprecated (Remove this as soon as minecraft offers anything better). + */ + @SuppressWarnings(DEPRECATION) + @Override + @Deprecated + public boolean isOpaqueCube(final IBlockState state) + { + return false; + } + + @NotNull + @Override + @SideOnly(Side.CLIENT) + public BlockRenderLayer getRenderLayer() + { + return BlockRenderLayer.SOLID; + } + + @Override + public boolean doesSideBlockRendering(final IBlockState state, final IBlockAccess world, final BlockPos pos, final EnumFacing face) + { + return false; + } +} diff --git a/src/main/java/com/minecolonies/coremod/blocks/ModBlocks.java b/src/main/java/com/minecolonies/coremod/blocks/ModBlocks.java index 1393315d74a..d82813626f1 100644 --- a/src/main/java/com/minecolonies/coremod/blocks/ModBlocks.java +++ b/src/main/java/com/minecolonies/coremod/blocks/ModBlocks.java @@ -4,6 +4,7 @@ import com.minecolonies.coremod.blocks.huts.*; import com.minecolonies.coremod.blocks.schematic.BlockWaypoint; import net.minecraft.block.Block; +import net.minecraft.block.material.Material; import net.minecraft.item.Item; import net.minecraftforge.registries.IForgeRegistry; @@ -22,47 +23,48 @@ public final class ModBlocks * References can be made to here. */ - public static BlockHutTownHall blockHutTownHall; - public static BlockHutCitizen blockHutCitizen; - public static BlockHutMiner blockHutMiner; - public static BlockHutLumberjack blockHutLumberjack; - public static BlockHutBaker blockHutBaker; - public static BlockHutBuilder blockHutBuilder; - public static BlockHutDeliveryman blockHutDeliveryman; - public static BlockHutBlacksmith blockHutBlacksmith; - public static BlockHutStonemason blockHutStonemason; - public static BlockHutFarmer blockHutFarmer; - public static BlockHutFisherman blockHutFisherman; - public static BlockBarracksTowerSubstitution blockBarracksTowerSubstitution; - public static BlockHutField blockHutField; - public static BlockHutGuardTower blockHutGuardTower; - public static BlockHutWareHouse blockHutWareHouse; - public static BlockHutShepherd blockHutShepherd; - public static BlockHutCowboy blockHutCowboy; - public static BlockHutSwineHerder blockHutSwineHerder; - public static BlockHutChickenHerder blockHutChickenHerder; - public static BlockHutBarracks blockHutBarracks; - public static BlockHutBarracksTower blockHutBarracksTower; - public static BlockHutCook blockHutCook; - public static BlockHutSmeltery blockHutSmeltery; - public static BlockHutComposter blockHutComposter; - public static BlockHutLibrary blockHutLibrary; - public static BlockHutArchery blockHutArchery; - public static BlockHutCombatAcademy blockHutCombatAcademy; - public static BlockHutSawmill blockHutSawmill; - public static BlockHutStoneSmeltery blockHutStoneSmeltery; - public static BlockHutCrusher blockHutCrusher; - public static BlockHutSifter blockHutSifter; + public static BlockHutTownHall blockHutTownHall; + public static BlockHutCitizen blockHutCitizen; + public static BlockHutMiner blockHutMiner; + public static BlockHutLumberjack blockHutLumberjack; + public static BlockHutBaker blockHutBaker; + public static BlockHutBuilder blockHutBuilder; + public static BlockHutDeliveryman blockHutDeliveryman; + public static BlockHutBlacksmith blockHutBlacksmith; + public static BlockHutStonemason blockHutStonemason; + public static BlockHutFarmer blockHutFarmer; + public static BlockHutFisherman blockHutFisherman; + public static BlockBarracksTowerSubstitution blockBarracksTowerSubstitution; + public static BlockHutField blockHutField; + public static BlockHutGuardTower blockHutGuardTower; + public static BlockHutWareHouse blockHutWareHouse; + public static BlockHutShepherd blockHutShepherd; + public static BlockHutCowboy blockHutCowboy; + public static BlockHutSwineHerder blockHutSwineHerder; + public static BlockHutChickenHerder blockHutChickenHerder; + public static BlockHutBarracks blockHutBarracks; + public static BlockHutBarracksTower blockHutBarracksTower; + public static BlockHutCook blockHutCook; + public static BlockHutSmeltery blockHutSmeltery; + public static BlockHutComposter blockHutComposter; + public static BlockHutLibrary blockHutLibrary; + public static BlockHutArchery blockHutArchery; + public static BlockHutCombatAcademy blockHutCombatAcademy; + public static BlockHutSawmill blockHutSawmill; + public static BlockHutStoneSmeltery blockHutStoneSmeltery; + public static BlockHutCrusher blockHutCrusher; + public static BlockHutSifter blockHutSifter; /** * Utility blocks. */ - public static BlockConstructionTape blockConstructionTape; - public static BlockMinecoloniesRack blockRack; - public static BlockWaypoint blockWayPoint; - public static BlockInfoPoster blockInfoPoster; - public static BlockBarrel blockBarrel; - public static BlockPostBox blockPostBox; + public static BlockConstructionTape blockConstructionTape; + public static BlockMinecoloniesRack blockRack; + public static BlockWaypoint blockWayPoint; + public static BlockInfoPoster blockInfoPoster; + public static BlockBarrel blockBarrel; + public static BlockPostBox blockPostBox; + public static BlockDecorationController blockDecorationPlacerholder; /** * Private constructor to hide the implicit public one. @@ -102,8 +104,8 @@ public static void init(final IForgeRegistry registry) blockHutCook = new BlockHutCook().registerBlock(registry); blockHutSmeltery = new BlockHutSmeltery().registerBlock(registry); blockHutComposter = new BlockHutComposter().registerBlock(registry); - blockHutLibrary = new BlockHutLibrary().registerBlock(registry); - blockHutArchery = new BlockHutArchery().registerBlock(registry); + blockHutLibrary = new BlockHutLibrary().registerBlock(registry); + blockHutArchery = new BlockHutArchery().registerBlock(registry); blockHutSawmill = new BlockHutSawmill().registerBlock(registry); blockHutCombatAcademy = new BlockHutCombatAcademy().registerBlock(registry); blockHutStoneSmeltery = new BlockHutStoneSmeltery().registerBlock(registry); @@ -116,7 +118,7 @@ public static void init(final IForgeRegistry registry) blockRack = new BlockMinecoloniesRack().registerBlock(registry); blockWayPoint = new BlockWaypoint().registerBlock(registry); blockPostBox = new BlockPostBox().registerBlock(registry); - + blockDecorationPlacerholder = new BlockDecorationController(Material.WOOD).registerBlock(registry); blockBarrel = new BlockBarrel().registerBlock(registry); } @@ -152,7 +154,7 @@ public static void registerItemBlock(final IForgeRegistry registry) blockHutStoneSmeltery.registerItemBlock(registry); blockHutCrusher.registerItemBlock(registry); blockHutSifter.registerItemBlock(registry); - + blockConstructionTape.registerItemBlock(registry); blockBarracksTowerSubstitution.registerItemBlock(registry); blockRack.registerItemBlock(registry); @@ -160,5 +162,6 @@ public static void registerItemBlock(final IForgeRegistry registry) blockInfoPoster.registerItemBlock(registry); blockBarrel.registerItemBlock(registry); blockPostBox.registerItemBlock(registry); + blockDecorationPlacerholder.registerItemBlock(registry); } } diff --git a/src/main/java/com/minecolonies/coremod/client/gui/WindowDecorationController.java b/src/main/java/com/minecolonies/coremod/client/gui/WindowDecorationController.java new file mode 100644 index 00000000000..6c13c133c19 --- /dev/null +++ b/src/main/java/com/minecolonies/coremod/client/gui/WindowDecorationController.java @@ -0,0 +1,187 @@ +package com.minecolonies.coremod.client.gui; + +import com.minecolonies.api.util.LanguageHandler; +import com.minecolonies.api.util.constant.Constants; +import com.minecolonies.blockout.Log; +import com.minecolonies.blockout.controls.Button; +import com.minecolonies.blockout.controls.ButtonHandler; +import com.minecolonies.blockout.controls.Label; +import com.minecolonies.blockout.controls.TextField; +import com.minecolonies.coremod.MineColonies; +import com.minecolonies.coremod.colony.ColonyManager; +import com.minecolonies.coremod.colony.ColonyView; +import com.minecolonies.coremod.colony.buildings.AbstractBuilding; +import com.minecolonies.coremod.colony.workorders.AbstractWorkOrder; +import com.minecolonies.coremod.colony.workorders.WorkOrderView; +import com.minecolonies.coremod.network.messages.DecorationBuildRequestMessage; +import com.minecolonies.coremod.network.messages.DecorationControllUpdateMessage; +import com.minecolonies.coremod.tileentities.TileEntityDecorationController; +import net.minecraft.client.Minecraft; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +import java.util.Optional; + +import static com.minecolonies.api.util.constant.WindowConstants.*; + +/** + * Window for a hut name entry. + */ +public class WindowDecorationController extends AbstractWindowSkeleton implements ButtonHandler +{ + /** + * The max length of the name. + */ + private static final int MAX_NAME_LENGTH = 100; + + /** + * Resource suffix of GUI xml file. + */ + private static final String HUT_NAME_RESOURCE_SUFFIX = ":gui/windowdecorationcontroller.xml"; + + /** + * The id of the level input. + */ + private static final String INPUT_LEVEL = "level"; + + /** + * The building associated to the GUI. + */ + private final TileEntityDecorationController controller; + + /** + * The world the player of the GUI is in. + */ + private final World world = Minecraft.getMinecraft().world; + + /** + * If the player opening the GUI is an isCreative. + */ + private boolean isCreative = Minecraft.getMinecraft().player.isCreative(); + + /** + * Constructor for a hut rename entry window. + * + * @param b {@link AbstractBuilding} + */ + public WindowDecorationController(final BlockPos b) + { + super(Constants.MOD_ID + HUT_NAME_RESOURCE_SUFFIX); + this.controller = (TileEntityDecorationController) world.getTileEntity(b); + registerButton(BUTTON_BUILD, this::confirmClicked); + registerButton(BUTTON_REPAIR, this::repairClicked); + registerButton(BUTTON_DONE, this::doneClicked); + registerButton(BUTTON_CANCEL, this::cancelClicked); + + final TextField textFieldName = findPaneOfTypeByID(INPUT_NAME, TextField.class); + textFieldName.setText(controller.getSchematicName()); + + final TextField textFieldLevel = findPaneOfTypeByID(INPUT_LEVEL, TextField.class); + textFieldLevel.setText(String.valueOf(controller.getLevel())); + + final ColonyView view = ColonyManager.getClosestColonyView(world, controller.getPos()); + + final Button buttonBuild = findPaneOfTypeByID(BUTTON_BUILD, Button.class); + + if (view != null) + { + final Optional wo = view.getWorkOrders().stream().filter(w -> w.getPos().equals(this.controller.getPos())).findFirst(); + if (wo.isPresent()) + { + + if (wo.get().getType() == AbstractWorkOrder.WorkOrderType.BUILD) + { + if (controller.getLevel() == 0) + { + buttonBuild.setLabel(LanguageHandler.format("com.minecolonies.coremod.gui.workerHuts.cancelBuild")); + } + else + { + buttonBuild.setLabel(LanguageHandler.format("com.minecolonies.coremod.gui.workerHuts.cancelUpgrade")); + } + findPaneByID(BUTTON_REPAIR).hide(); + } + else if (wo.get().getType() == AbstractWorkOrder.WorkOrderType.BUILD) + { + buttonBuild.setLabel(LanguageHandler.format("com.minecolonies.coremod.gui.workerHuts.cancelRepair")); + findPaneByID(BUTTON_REPAIR).hide(); + } + } + } + + if (controller.getLevel() == 0) + { + findPaneByID(BUTTON_REPAIR).hide(); + } + + if (!isCreative) + { + textFieldName.disable(); + textFieldLevel.disable(); + findPaneByID(BUTTON_DONE).hide(); + } + else + { + findPaneOfTypeByID("nameLabel", Label.class).setLabelText(LanguageHandler.format("com.minecolonies.coremod.gui.deco.namescan")); + } + } + + /** + * When cancel is clicked. + */ + private void cancelClicked() + { + close(); + } + + /** + * Done is clicked to save the new settings. + */ + private void doneClicked() + { + if (isCreative) + { + String name = findPaneOfTypeByID(INPUT_NAME, TextField.class).getText(); + + if (name.length() > MAX_NAME_LENGTH) + { + name = name.substring(0, MAX_NAME_LENGTH); + LanguageHandler.sendPlayerMessage(Minecraft.getMinecraft().player, "com.minecolonies.coremod.gui.name.tooLong", name); + } + + final String levelString = findPaneOfTypeByID(INPUT_LEVEL, TextField.class).getText(); + try + { + final int level = Integer.parseInt(levelString); + MineColonies.getNetwork().sendToServer(new DecorationControllUpdateMessage(controller.getPos(), name, level)); + controller.setSchematicName(name); + controller.setLevel(level); + close(); + } + catch (final NumberFormatException ex) + { + Log.getLogger().warn("Error parsing number: " + levelString, ex); + } + } + } + + /** + * On confirm button. + */ + private void confirmClicked() + { + MineColonies.getNetwork() + .sendToServer(new DecorationBuildRequestMessage(controller.getPos(), controller.getSchematicName(), controller.getLevel() + 1, world.provider.getDimension())); + close(); + } + + /** + * Action when repair button is clicked. + */ + private void repairClicked() + { + MineColonies.getNetwork() + .sendToServer(new DecorationBuildRequestMessage(controller.getPos(), controller.getSchematicName(), controller.getLevel(), world.provider.getDimension())); + close(); + } +} diff --git a/src/main/java/com/minecolonies/coremod/client/gui/WindowMinecoloniesBuildTool.java b/src/main/java/com/minecolonies/coremod/client/gui/WindowMinecoloniesBuildTool.java index 535cba6a3a9..c2617e59924 100644 --- a/src/main/java/com/minecolonies/coremod/client/gui/WindowMinecoloniesBuildTool.java +++ b/src/main/java/com/minecolonies/coremod/client/gui/WindowMinecoloniesBuildTool.java @@ -1,5 +1,6 @@ package com.minecolonies.coremod.client.gui; +import com.ldtteam.structures.lib.BlueprintUtils; import com.ldtteam.structurize.util.BlockUtils; import com.minecolonies.api.util.constant.TranslationConstants; import com.minecolonies.coremod.MineColonies; @@ -12,6 +13,7 @@ import com.ldtteam.structurize.management.StructureName; import com.ldtteam.structurize.placementhandlers.PlacementError; import com.ldtteam.structures.helpers.Settings; +import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.util.math.BlockPos; @@ -55,13 +57,16 @@ public WindowMinecoloniesBuildTool(@Nullable final BlockPos pos) @Override public void place(final StructureName structureName) { + final BlockPos offset = BlueprintUtils.getPrimaryBlockOffset(Settings.instance.getActiveStructure().getBluePrint());; + final IBlockState state = Settings.instance.getActiveStructure().getBlockState(offset); MineColonies.getNetwork().sendToServer(new BuildToolPlaceMessage( structureName.toString(), structureName.toString(), Settings.instance.getPosition(), Settings.instance.getRotation(), structureName.isHut(), - Settings.instance.getMirror())); + Settings.instance.getMirror(), + state)); } @Override @@ -79,6 +84,8 @@ public boolean pasteDirectly() @Override public void paste(final StructureName name, final boolean complete) { + final BlockPos offset = BlueprintUtils.getPrimaryBlockOffset(Settings.instance.getActiveStructure().getBluePrint());; + final IBlockState state = Settings.instance.getActiveStructure().getBlockState(offset); MineColonies.getNetwork().sendToServer(new BuildToolPasteMessage( name.toString(), name.toString(), @@ -86,7 +93,8 @@ public void paste(final StructureName name, final boolean complete) Settings.instance.getRotation(), name.isHut(), Settings.instance.getMirror(), - complete, Settings.instance.getFreeMode())); + complete, Settings.instance.getFreeMode(), + state)); } @Override diff --git a/src/main/java/com/minecolonies/coremod/client/gui/WindowMoveBuilding.java b/src/main/java/com/minecolonies/coremod/client/gui/WindowMoveBuilding.java index 9be7dd8e0db..082522929ae 100644 --- a/src/main/java/com/minecolonies/coremod/client/gui/WindowMoveBuilding.java +++ b/src/main/java/com/minecolonies/coremod/client/gui/WindowMoveBuilding.java @@ -1,5 +1,6 @@ package com.minecolonies.coremod.client.gui; +import com.ldtteam.structures.lib.BlueprintUtils; import com.ldtteam.structurize.util.PlacementSettings; import com.minecolonies.api.util.BlockUtils; import com.minecolonies.api.util.Log; @@ -16,6 +17,7 @@ import com.ldtteam.structurize.network.messages.SchematicRequestMessage; import com.ldtteam.structures.helpers.Settings; import com.ldtteam.structures.helpers.Structure; +import net.minecraft.block.state.IBlockState; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import net.minecraft.client.Minecraft; @@ -263,12 +265,16 @@ private void confirmClicked() } else { + final BlockPos offset = BlueprintUtils.getPrimaryBlockOffset(Settings.instance.getActiveStructure().getBluePrint());; + final IBlockState state = Settings.instance.getActiveStructure().getBlockState(offset); MineColonies.getNetwork().sendToServer(new BuildingMoveMessage( structureName.toString(), structureName.toString(), Settings.instance.getPosition(), Settings.instance.getRotation(), - Settings.instance.getMirror(), building)); + Settings.instance.getMirror(), + building, + state)); } if (!GuiScreen.isShiftKeyDown()) diff --git a/src/main/java/com/minecolonies/coremod/colony/buildings/registry/BuildingRegistry.java b/src/main/java/com/minecolonies/coremod/colony/buildings/registry/BuildingRegistry.java index f9606a4acdf..8c7b4ed15cf 100644 --- a/src/main/java/com/minecolonies/coremod/colony/buildings/registry/BuildingRegistry.java +++ b/src/main/java/com/minecolonies/coremod/colony/buildings/registry/BuildingRegistry.java @@ -5,6 +5,7 @@ import com.ldtteam.structures.helpers.Structure; import com.ldtteam.structurize.util.PlacementSettings; import com.minecolonies.api.util.BlockPosUtil; +import com.minecolonies.api.util.BlockUtils; import com.minecolonies.api.util.Log; import com.minecolonies.coremod.blocks.AbstractBlockHut; import com.minecolonies.coremod.blocks.BlockPostBox; @@ -239,6 +240,7 @@ public static AbstractBuilding create(final Colony colony, @NotNull final TileEn if (building != null && parent.getWorld() != null && !(building instanceof PostBox)) { + building.setRotation(BlockUtils.getRotationFromFacing(parent.getWorld().getBlockState(parent.getPosition()).getValue(AbstractBlockHut.FACING))); final WorkOrderBuildBuilding workOrder = new WorkOrderBuildBuilding(building, 1); final Structure wrapper = new Structure(parent.getWorld(), workOrder.getStructureName(), new PlacementSettings()); final Tuple, Tuple> corners @@ -247,8 +249,10 @@ public static AbstractBuilding create(final Colony colony, @NotNull final TileEn wrapper, workOrder.getRotation(parent.getWorld()), workOrder.isMirrored()); + building.setCorners(corners.getFirst().getFirst(), corners.getFirst().getSecond(), corners.getSecond().getFirst(), corners.getSecond().getSecond()); building.setHeight(wrapper.getHeight()); + ConstructionTapeHelper.placeConstructionTape(building.getLocation(), corners, parent.getWorld()); } return building; diff --git a/src/main/java/com/minecolonies/coremod/colony/workorders/AbstractWorkOrder.java b/src/main/java/com/minecolonies/coremod/colony/workorders/AbstractWorkOrder.java index c61876bc3e8..fa8f23ba620 100644 --- a/src/main/java/com/minecolonies/coremod/colony/workorders/AbstractWorkOrder.java +++ b/src/main/java/com/minecolonies/coremod/colony/workorders/AbstractWorkOrder.java @@ -27,6 +27,7 @@ public abstract class AbstractWorkOrder /** * NBT for storage. */ + private static final String TAG_BUILDING = "building"; private static final String TAG_TYPE = "type"; private static final String TAG_TH_PRIORITY = "priority"; private static final String TAG_ID = "id"; @@ -71,6 +72,11 @@ public abstract class AbstractWorkOrder */ private boolean changed = false; + /** + * The location to built at. + */ + protected BlockPos buildingLocation; + /** * Default constructor; we also start with a new id and replace it during loading; * this greatly simplifies creating subclasses. @@ -185,6 +191,7 @@ else if (compound.hasKey(TAG_CLAIMED_BY_BUILDING)) { claimedBy = BlockPosUtil.readFromNBT(compound, TAG_CLAIMED_BY_BUILDING); } + buildingLocation = BlockPosUtil.readFromNBT(compound, TAG_BUILDING); } /** @@ -350,6 +357,7 @@ public void writeToNBT(@NotNull final NBTTagCompound compound) { BlockPosUtil.writeToNBT(compound, TAG_CLAIMED_BY_BUILDING, claimedBy); } + BlockPosUtil.writeToNBT(compound, TAG_BUILDING, buildingLocation); } /** @@ -380,6 +388,8 @@ public void serializeViewNetworkData(@NotNull final ByteBuf buf) BlockPosUtil.writeToByteBuf(buf, claimedBy == null ? BlockPos.ORIGIN : claimedBy); buf.writeInt(getType().ordinal()); ByteBufUtils.writeUTF8String(buf, getValue()); + BlockPosUtil.writeToByteBuf(buf, buildingLocation == null ? BlockPos.ORIGIN : buildingLocation); + //value is upgradeName and upgradeLevel for workOrderBuild } diff --git a/src/main/java/com/minecolonies/coremod/colony/workorders/WorkOrderBuild.java b/src/main/java/com/minecolonies/coremod/colony/workorders/WorkOrderBuild.java index 4f0337e8769..9e097cd0bf4 100644 --- a/src/main/java/com/minecolonies/coremod/colony/workorders/WorkOrderBuild.java +++ b/src/main/java/com/minecolonies/coremod/colony/workorders/WorkOrderBuild.java @@ -1,9 +1,7 @@ package com.minecolonies.coremod.colony.workorders; -import com.minecolonies.api.util.BlockUtils; import com.minecolonies.api.util.LanguageHandler; import com.minecolonies.api.util.Log; -import com.minecolonies.coremod.blocks.AbstractBlockHut; import com.minecolonies.coremod.colony.CitizenData; import com.minecolonies.coremod.colony.Colony; import com.minecolonies.coremod.colony.buildings.AbstractBuilding; @@ -11,7 +9,6 @@ import com.minecolonies.coremod.entity.ai.citizen.builder.ConstructionTapeHelper; import com.ldtteam.structurize.management.StructureName; import com.ldtteam.structurize.management.Structures; -import net.minecraft.block.state.IBlockState; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -175,14 +172,6 @@ protected String getValue() @Override public int getRotation(final World world) { - if (buildingRotation == 0 && world != null) - { - final IBlockState blockState = world.getBlockState(buildingLocation); - if (blockState.getBlock() instanceof AbstractBlockHut) - { - return BlockUtils.getRotationFromFacing(blockState.getValue(AbstractBlockHut.FACING)); - } - } return buildingRotation; } diff --git a/src/main/java/com/minecolonies/coremod/colony/workorders/WorkOrderBuildDecoration.java b/src/main/java/com/minecolonies/coremod/colony/workorders/WorkOrderBuildDecoration.java index e9f49c5a9cf..bf6f846b0f8 100644 --- a/src/main/java/com/minecolonies/coremod/colony/workorders/WorkOrderBuildDecoration.java +++ b/src/main/java/com/minecolonies/coremod/colony/workorders/WorkOrderBuildDecoration.java @@ -1,6 +1,5 @@ package com.minecolonies.coremod.colony.workorders; -import com.minecolonies.api.util.BlockPosUtil; import com.minecolonies.api.util.LanguageHandler; import com.minecolonies.api.util.Log; import com.minecolonies.coremod.colony.CitizenData; @@ -8,11 +7,14 @@ import com.minecolonies.coremod.entity.ai.citizen.builder.ConstructionTapeHelper; import com.ldtteam.structurize.management.StructureName; import com.ldtteam.structurize.management.Structures; +import com.minecolonies.coremod.tileentities.TileEntityDecorationController; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import org.jetbrains.annotations.NotNull; +import static com.minecolonies.api.util.constant.NbtTagConstants.TAG_LEVEL; import static com.minecolonies.api.util.constant.Suppression.UNUSED_METHOD_PARAMETERS_SHOULD_BE_REMOVED; /** @@ -23,7 +25,6 @@ public class WorkOrderBuildDecoration extends AbstractWorkOrder /** * NBT Tags for storage. */ - private static final String TAG_BUILDING = "building"; private static final String TAG_WORKORDER_NAME = "workOrderName"; private static final String TAG_IS_CLEARED = "cleared"; private static final String TAG_IS_REQUESTED = "requested"; @@ -35,14 +36,13 @@ public class WorkOrderBuildDecoration extends AbstractWorkOrder private static final String TAG_AMOUNT_OF_RES = "resQuantity"; protected boolean isBuildingMirrored; - protected BlockPos buildingLocation; protected int buildingRotation; protected String structureName; protected String md5; protected boolean cleared; protected String workOrderName; protected int amountOfRes; - + protected boolean levelUp = false; protected boolean hasSentMessageForThisWorkOrder = false; private boolean requested; @@ -77,6 +77,14 @@ public WorkOrderBuildDecoration(final String structureName, final String workOrd this.requested = false; } + /** + * Make a decoration level up with this. + */ + public void setLevelUp() + { + this.levelUp = true; + } + /** * Get the name of the work order. * @@ -96,7 +104,6 @@ public String getName() public void readFromNBT(@NotNull final NBTTagCompound compound, final WorkManager manager) { super.readFromNBT(compound, manager); - buildingLocation = BlockPosUtil.readFromNBT(compound, TAG_BUILDING); final StructureName sn = new StructureName(compound.getString(TAG_SCHEMATIC_NAME)); structureName = sn.toString(); workOrderName = compound.getString(TAG_WORKORDER_NAME); @@ -121,6 +128,7 @@ public void readFromNBT(@NotNull final NBTTagCompound compound, final WorkManage requested = compound.getBoolean(TAG_IS_REQUESTED); isBuildingMirrored = compound.getBoolean(TAG_IS_MIRRORED); amountOfRes = compound.getInteger(TAG_AMOUNT_OF_RES); + levelUp = compound.getBoolean(TAG_LEVEL); } /** @@ -132,7 +140,6 @@ public void readFromNBT(@NotNull final NBTTagCompound compound, final WorkManage public void writeToNBT(@NotNull final NBTTagCompound compound) { super.writeToNBT(compound); - BlockPosUtil.writeToNBT(compound, TAG_BUILDING, buildingLocation); if (workOrderName != null) { compound.setString(TAG_WORKORDER_NAME, workOrderName); @@ -154,6 +161,7 @@ public void writeToNBT(@NotNull final NBTTagCompound compound) compound.setBoolean(TAG_IS_REQUESTED, requested); compound.setBoolean(TAG_IS_MIRRORED, isBuildingMirrored); compound.setInteger(TAG_AMOUNT_OF_RES, amountOfRes); + compound.setBoolean(TAG_LEVEL, levelUp); } @Override @@ -225,6 +233,21 @@ public void onAdded(final Colony colony, final boolean readingFromNbt) } } + @Override + public void onCompleted(final Colony colony) + { + super.onCompleted(colony); + + if (this.levelUp) + { + final TileEntity tileEntity = colony.getWorld().getTileEntity(buildingLocation); + if (tileEntity instanceof TileEntityDecorationController) + { + ((TileEntityDecorationController) tileEntity).setLevel(((TileEntityDecorationController) tileEntity).getLevel() + 1); + } + } + } + @Override public void onRemoved(final Colony colony) { diff --git a/src/main/java/com/minecolonies/coremod/colony/workorders/WorkOrderView.java b/src/main/java/com/minecolonies/coremod/colony/workorders/WorkOrderView.java index 2c6983a20c2..bf59d272f50 100644 --- a/src/main/java/com/minecolonies/coremod/colony/workorders/WorkOrderView.java +++ b/src/main/java/com/minecolonies/coremod/colony/workorders/WorkOrderView.java @@ -17,17 +17,17 @@ public class WorkOrderView /** * The work orders id. */ - private int id; + private int id; /** * The priority. */ - private int priority; + private int priority; /** * Its description. */ - private String value; + private String value; /** * The type (defined by an enum). @@ -37,7 +37,12 @@ public class WorkOrderView /** * Claimed by building id pos. */ - private BlockPos claimedBy; + private BlockPos claimedBy; + + /** + * Position where its being built at. + */ + private BlockPos pos; /** * Public constructor of the WorkOrderView. @@ -132,5 +137,15 @@ public void deserialize(@NotNull final ByteBuf buf) claimedBy = BlockPosUtil.readFromByteBuf(buf); type = AbstractWorkOrder.WorkOrderType.values()[buf.readInt()]; value = ByteBufUtils.readUTF8String(buf); + pos = BlockPosUtil.readFromByteBuf(buf); + } + + /** + * Get the position of the workorder. + * @return the position + */ + public BlockPos getPos() + { + return this.pos; } } diff --git a/src/main/java/com/minecolonies/coremod/entity/ai/basic/AbstractEntityAIStructure.java b/src/main/java/com/minecolonies/coremod/entity/ai/basic/AbstractEntityAIStructure.java index d020287e9ff..981387c5121 100644 --- a/src/main/java/com/minecolonies/coremod/entity/ai/basic/AbstractEntityAIStructure.java +++ b/src/main/java/com/minecolonies/coremod/entity/ai/basic/AbstractEntityAIStructure.java @@ -10,6 +10,8 @@ import com.minecolonies.api.crafting.ItemStorage; import com.minecolonies.api.util.*; import com.minecolonies.api.util.constant.TypeConstants; +import com.minecolonies.coremod.blocks.BlockDecorationController; +import com.minecolonies.coremod.blocks.ModBlocks; import com.minecolonies.coremod.colony.buildings.AbstractBuildingStructureBuilder; import com.minecolonies.coremod.colony.jobs.AbstractJobStructure; import com.minecolonies.coremod.entity.EntityCitizen; @@ -43,6 +45,7 @@ import java.util.*; import java.util.function.Function; import java.util.function.Supplier; +import java.util.stream.Collectors; import static com.minecolonies.api.util.constant.Suppression.MULTIPLE_LOOPS_OVER_THE_SAME_SET_SHOULD_BE_COMBINED; import static com.minecolonies.coremod.entity.ai.statemachine.states.AIWorkerState.*; @@ -450,7 +453,7 @@ private boolean placeBlockAt(@NotNull final IBlockState blockState, @NotNull fin world.setBlockToAir(coords); } - final Object result = handlers.handle(world, coords, blockState, job.getStructure().getTileEntityData(job.getStructure().getLocalPosition()), false, job.getStructure().getPosition()); + final Object result = handlers.handle(world, coords, blockState, job.getStructure().getTileEntityData(job.getStructure().getLocalPosition()), false, job.getStructure().getPosition(), job.getStructure().getSettings()); if (result instanceof IPlacementHandler.ActionProcessingResult) { if (result == IPlacementHandler.ActionProcessingResult.ACCEPT) @@ -682,7 +685,8 @@ public static boolean isBlockFree(@Nullable final Block block, final int metadat || BlockUtils.isWater(block.getDefaultState()) || block.equals(Blocks.LEAVES) || block.equals(Blocks.LEAVES2) - || (block.equals(Blocks.DOUBLE_PLANT) && Utils.testFlag(metadata, 0x08)); + || (block.equals(Blocks.DOUBLE_PLANT) && Utils.testFlag(metadata, 0x08)) + || block == ModBlocks.blockDecorationPlacerholder; } /* @@ -814,6 +818,8 @@ public void loadStructure(@NotNull final String name, final int rotateTimes, fin { job.getStructure().rotate(BlockPosUtil.getRotationFromRotations(rotateTimes), world, position, isMirrored ? Mirror.FRONT_BACK : Mirror.NONE); job.getStructure().setPosition(position); + job.getStructure().setPlacementSettings(new PlacementSettings(isMirrored ? Mirror.FRONT_BACK : Mirror.NONE, BlockPosUtil.getRotationFromRotations(rotateTimes))); + } catch (final NullPointerException ex) { @@ -1043,6 +1049,8 @@ else if (entity instanceof EntityArmorStand) request.add(entity.getPickedResult(new RayTraceResult(worker))); } + request.removeIf(ItemStackUtils::isEmpty); + if (!Configurations.gameplay.builderInfiniteResources) { if (checkForListInInvAndRequest(this, new ArrayList<>(request), true)) diff --git a/src/main/java/com/minecolonies/coremod/entity/ai/util/StructureIterator.java b/src/main/java/com/minecolonies/coremod/entity/ai/util/StructureIterator.java index b5ca2213c1b..a8f7c38666b 100644 --- a/src/main/java/com/minecolonies/coremod/entity/ai/util/StructureIterator.java +++ b/src/main/java/com/minecolonies/coremod/entity/ai/util/StructureIterator.java @@ -273,6 +273,7 @@ private static Structure loadStructure( //put the building into place tempSchematic.rotate(BlockPosUtil.getRotationFromRotations(rotation), targetWorld, buildingLocation, mirror); tempSchematic.setPosition(buildingLocation); + tempSchematic.setPlacementSettings(new PlacementSettings(mirror, BlockPosUtil.getRotationFromRotations(rotation))); if (blockProgress != null) { tempSchematic.setLocalPosition(blockProgress); diff --git a/src/main/java/com/minecolonies/coremod/event/EventHandler.java b/src/main/java/com/minecolonies/coremod/event/EventHandler.java index 05cb5d14ea2..82f2fc49c02 100644 --- a/src/main/java/com/minecolonies/coremod/event/EventHandler.java +++ b/src/main/java/com/minecolonies/coremod/event/EventHandler.java @@ -620,13 +620,14 @@ private static boolean canPlayerPlaceTownHallHere(@NotNull final World world, @N return false; } - if (Configurations.gameplay.protectVillages - && world.getVillageCollection().getNearestVillage(pos, Configurations.gameplay.workingRangeTownHallChunks * BLOCKS_PER_CHUNK) != null) + + if (!world.isRemote + && Configurations.gameplay.protectVillages + && world.getVillageCollection().getNearestVillage(pos, Configurations.gameplay.workingRangeTownHallChunks * BLOCKS_PER_CHUNK) != null) { - Log.getLogger().warn("Village close by!"); - return false; + Log.getLogger().warn("Village close by!"); + return false; } - return true; } diff --git a/src/main/java/com/minecolonies/coremod/inventory/GuiHandler.java b/src/main/java/com/minecolonies/coremod/inventory/GuiHandler.java index 0abc66d2cd0..d4cadec32b1 100644 --- a/src/main/java/com/minecolonies/coremod/inventory/GuiHandler.java +++ b/src/main/java/com/minecolonies/coremod/inventory/GuiHandler.java @@ -9,6 +9,7 @@ import com.minecolonies.coremod.colony.buildings.views.AbstractBuildingView; import com.minecolonies.coremod.tileentities.ScarecrowTileEntity; import com.minecolonies.coremod.tileentities.TileEntityColonyBuilding; +import com.minecolonies.coremod.tileentities.TileEntityDecorationController; import com.minecolonies.coremod.tileentities.TileEntityRack; import net.minecraft.client.gui.inventory.GuiChest; import net.minecraft.entity.player.EntityPlayer; diff --git a/src/main/java/com/minecolonies/coremod/network/messages/BuildToolPasteMessage.java b/src/main/java/com/minecolonies/coremod/network/messages/BuildToolPasteMessage.java index 3a0dfce6fbc..a19cdb5aee0 100644 --- a/src/main/java/com/minecolonies/coremod/network/messages/BuildToolPasteMessage.java +++ b/src/main/java/com/minecolonies/coremod/network/messages/BuildToolPasteMessage.java @@ -19,10 +19,13 @@ import io.netty.buffer.ByteBuf; import net.minecraft.block.Block; import net.minecraft.block.BlockChest; +import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTUtil; import net.minecraft.stats.StatList; import net.minecraft.util.Mirror; import net.minecraft.util.math.BlockPos; @@ -48,6 +51,11 @@ public class BuildToolPasteMessage extends AbstractMessage { /** - * Language key for missing hut message. + * Position of building. */ private BlockPos buildingId; + + /** + * The state at the offset position. + */ + private IBlockState state; + private String structureName; private String workOrderName; private int rotation; @@ -64,20 +70,23 @@ public BuildingMoveMessage() /** * Create the building that was made with the build tool. * Item in inventory required - * @param structureName String representation of a structure + * + * @param structureName String representation of a structure * @param workOrderName String name of the work order * @param pos BlockPos * @param rotation int representation of the rotation * @param mirror the mirror of the building or decoration. - * @param building + * @param building the building. + * @param state the state. */ public BuildingMoveMessage( - final String structureName, - final String workOrderName, - final BlockPos pos, - final int rotation, - final Mirror mirror, - final AbstractBuildingView building) + final String structureName, + final String workOrderName, + final BlockPos pos, + final int rotation, + final Mirror mirror, + final AbstractBuildingView building, + final IBlockState state) { super(); this.structureName = structureName; @@ -86,6 +95,7 @@ public BuildingMoveMessage( this.rotation = rotation; this.mirror = mirror == Mirror.FRONT_BACK; this.buildingId = building.getID(); + this.state = state; } /** @@ -102,6 +112,7 @@ public void fromBytes(@NotNull final ByteBuf buf) rotation = buf.readInt(); mirror = buf.readBoolean(); buildingId = BlockPosUtil.readFromByteBuf(buf); + state = NBTUtil.readBlockState(ByteBufUtils.readTag(buf)); } /** @@ -118,6 +129,7 @@ public void toBytes(@NotNull final ByteBuf buf) buf.writeInt(rotation); buf.writeBoolean(mirror); BlockPosUtil.writeToByteBuf(buf, buildingId); + ByteBufUtils.writeTag(buf, NBTUtil.writeBlockState(new NBTTagCompound(), state)); } @Override @@ -129,7 +141,7 @@ public void messageOnServerThread(final BuildingMoveMessage message, final Entit player.sendMessage(new TextComponentString("Can not build " + message.workOrderName + ": schematic missing!")); return; } - handleHut(CompatibilityUtils.getWorld(player), player, sn, message.rotation, message.pos, message.mirror, message.buildingId); + handleHut(CompatibilityUtils.getWorld(player), player, sn, message.rotation, message.pos, message.mirror, message.buildingId, message.state); } /** @@ -142,19 +154,20 @@ public void messageOnServerThread(final BuildingMoveMessage message, final Entit * @param buildPos The location the hut is being placed. * @param mirror Whether or not the strcture is mirrored. * @param oldBuildingId The old building id. + * @param state the hut state. */ private static void handleHut( - @NotNull final World world, @NotNull final EntityPlayer player, - final StructureName sn, - final int rotation, @NotNull final BlockPos buildPos, final boolean mirror, final BlockPos oldBuildingId) + @NotNull final World world, @NotNull final EntityPlayer player, + final StructureName sn, + final int rotation, @NotNull final BlockPos buildPos, final boolean mirror, final BlockPos oldBuildingId, final IBlockState state) { final String hut = sn.getSection(); final Block block = Block.getBlockFromName(Constants.MOD_ID + ":blockHut" + hut); final Colony tempColony = ColonyManager.getClosestColony(world, buildPos); if (tempColony != null - && (!tempColony.getPermissions().hasPermission(player, Action.MANAGE_HUTS) - && !(block instanceof BlockHutTownHall - && !ColonyManager.isTooCloseToColony(world, buildPos)))) + && (!tempColony.getPermissions().hasPermission(player, Action.MANAGE_HUTS) + && !(block instanceof BlockHutTownHall + && !ColonyManager.isTooCloseToColony(world, buildPos)))) { return; } @@ -168,7 +181,7 @@ private static void handleHut( } world.destroyBlock(oldBuildingId, false); } - else if(oldBuilding instanceof BuildingWareHouse && tempColony != null) + else if (oldBuilding instanceof BuildingWareHouse && tempColony != null) { tempColony.getBuildingManager().setWareHouse(null); } @@ -178,7 +191,7 @@ else if(oldBuilding instanceof BuildingWareHouse && tempColony != null) world.destroyBlock(oldBuildingId, false); world.destroyBlock(buildPos, true); - world.setBlockState(buildPos, block.getDefaultState().withRotation(BlockUtils.getRotation(rotation))); + world.setBlockState(buildPos, state.withRotation(BlockPosUtil.getRotationFromRotations(rotation))); ((AbstractBlockHut) block).onBlockPlacedByBuildTool(world, buildPos, world.getBlockState(buildPos), player, null, mirror, sn.getStyle()); setupBuilding(world, player, sn, rotation, buildPos, mirror, oldBuilding); } @@ -186,18 +199,19 @@ else if(oldBuilding instanceof BuildingWareHouse && tempColony != null) /** * setup the building once it has been placed. - * @param world World the hut is being placed into. - * @param player Who placed the hut. - * @param sn The name of the structure. - * @param rotation The number of times the structure should be rotated. - * @param buildPos The location the hut is being placed. - * @param mirror Whether or not the strcture is mirrored. + * + * @param world World the hut is being placed into. + * @param player Who placed the hut. + * @param sn The name of the structure. + * @param rotation The number of times the structure should be rotated. + * @param buildPos The location the hut is being placed. + * @param mirror Whether or not the strcture is mirrored. * @param oldBuilding The old building id. */ private static void setupBuilding( - @NotNull final World world, @NotNull final EntityPlayer player, - final StructureName sn, - final int rotation, @NotNull final BlockPos buildPos, final boolean mirror, @Nullable final AbstractBuilding oldBuilding) + @NotNull final World world, @NotNull final EntityPlayer player, + final StructureName sn, + final int rotation, @NotNull final BlockPos buildPos, final boolean mirror, @Nullable final AbstractBuilding oldBuilding) { @Nullable final AbstractBuilding building = ColonyManager.getBuilding(world, buildPos); @@ -229,8 +243,8 @@ private static void setupBuilding( if (oldBuilding instanceof AbstractBuildingWorker) { - final List workers = ((AbstractBuildingWorker) oldBuilding).getAssignedCitizen(); - for(final CitizenData citizen : workers) + final List workers = oldBuilding.getAssignedCitizen(); + for (final CitizenData citizen : workers) { citizen.setWorkBuilding(null); citizen.setWorkBuilding((AbstractBuildingWorker) building); @@ -240,15 +254,15 @@ private static void setupBuilding( if (oldBuilding instanceof BuildingBaker) { - for (final Map.Entry> task :((BuildingBaker) oldBuilding).getTasks().entrySet()) + for (final Map.Entry> task : ((BuildingBaker) oldBuilding).getTasks().entrySet()) { - for(final BakingProduct product : task.getValue()) + for (final BakingProduct product : task.getValue()) { ((BuildingBaker) building).addToTasks(task.getKey(), product); } } } - else if(oldBuilding instanceof BuildingDeliveryman) + else if (oldBuilding instanceof BuildingDeliveryman) { ((BuildingDeliveryman) building).setBuildingToDeliver(((BuildingDeliveryman) oldBuilding).getBuildingToDeliver()); } @@ -256,7 +270,7 @@ else if(oldBuilding instanceof BuildingDeliveryman) if (oldBuilding instanceof BuildingHome) { final List residents = oldBuilding.getAssignedCitizen(); - for(final CitizenData citizen : residents) + for (final CitizenData citizen : residents) { citizen.setHomeBuilding(building); building.assignCitizen(citizen); diff --git a/src/main/java/com/minecolonies/coremod/network/messages/DecorationBuildRequestMessage.java b/src/main/java/com/minecolonies/coremod/network/messages/DecorationBuildRequestMessage.java new file mode 100644 index 00000000000..e7eb2828263 --- /dev/null +++ b/src/main/java/com/minecolonies/coremod/network/messages/DecorationBuildRequestMessage.java @@ -0,0 +1,140 @@ +package com.minecolonies.coremod.network.messages; + +import com.minecolonies.api.colony.permissions.Action; +import com.minecolonies.api.util.BlockPosUtil; +import com.minecolonies.api.util.BlockUtils; +import com.minecolonies.coremod.blocks.BlockDecorationController; +import com.minecolonies.coremod.colony.Colony; +import com.minecolonies.coremod.colony.ColonyManager; +import com.minecolonies.coremod.colony.workorders.AbstractWorkOrder; +import com.minecolonies.coremod.colony.workorders.WorkOrderBuildDecoration; +import com.minecolonies.coremod.tileentities.TileEntityDecorationController; +import io.netty.buffer.ByteBuf; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; +import net.minecraftforge.fml.common.network.ByteBufUtils; +import net.minecraftforge.fml.common.network.simpleimpl.IMessage; +import org.jetbrains.annotations.NotNull; + +import java.util.Map; +import java.util.Optional; + +/** + * Adds a entry to the builderRequired map. + */ +public class DecorationBuildRequestMessage extends AbstractMessage +{ + /** + * The id of the building. + */ + private BlockPos pos; + + /** + * The name of the decoration. + */ + private String name; + + /** + * The level of the decoration. + */ + private int level; + + /** + * The dimension. + */ + private int dimension; + + /** + * Empty constructor used when registering the message. + */ + public DecorationBuildRequestMessage() + { + super(); + } + + /** + * Creates a build request for a decoration. + * @param pos the position of it. + * @param name it's name. + * @param level the level. + */ + public DecorationBuildRequestMessage(@NotNull final BlockPos pos, final String name, final int level, final int dimension) + { + super(); + this.pos = pos; + this.name = name; + this.level = level; + this.dimension = dimension; + } + + @Override + public void fromBytes(@NotNull final ByteBuf buf) + { + this.pos = BlockPosUtil.readFromByteBuf(buf); + this.name = ByteBufUtils.readUTF8String(buf); + this.level = buf.readInt(); + this.dimension = buf.readInt(); + } + + @Override + public void toBytes(@NotNull final ByteBuf buf) + { + BlockPosUtil.writeToByteBuf(buf, this.pos); + ByteBufUtils.writeUTF8String(buf, this.name); + buf.writeInt(this.level); + buf.writeInt(this.dimension); + } + + @Override + public void messageOnServerThread(final DecorationBuildRequestMessage message, final EntityPlayerMP player) + { + final Colony colony = ColonyManager.getColonyByPosFromDim(message.dimension, message.pos); + if (colony == null) + { + return; + } + + //Verify player has permission to change this huts settings + if (!colony.getPermissions().hasPermission(player, Action.MANAGE_HUTS)) + { + return; + } + + final TileEntity entity = player.getServerWorld().getTileEntity(message.pos); + if (entity instanceof TileEntityDecorationController) + { + final Optional> wo = colony.getWorkManager().getWorkOrders().entrySet().stream() + .filter(entry -> entry.getValue() instanceof WorkOrderBuildDecoration) + .filter(entry -> ((WorkOrderBuildDecoration) entry.getValue()).getBuildingLocation().equals(message.pos)).findFirst(); + + if (wo.isPresent()) + { + colony.getWorkManager().removeWorkOrder(wo.get().getKey()); + return; + } + final IBlockState state = player.getServerWorld().getBlockState(message.pos); + final EnumFacing facing = state.getValue(BlockDecorationController.FACING); + final EnumFacing basic = ((TileEntityDecorationController) entity).getBasicFacing(); + int difference = facing.getHorizontalIndex() - basic.getHorizontalIndex(); + if (difference < 0) + { + difference += 4; + } + + final WorkOrderBuildDecoration order = new WorkOrderBuildDecoration(message.name + message.level, + message.name + message.level, + difference, + message.pos, + state.getValue(BlockDecorationController.MIRROR)); + + if (message.level != ((TileEntityDecorationController) entity).getLevel()) + { + order.setLevelUp(); + } + colony.getWorkManager().addWorkOrder(order, false); + } + } +} diff --git a/src/main/java/com/minecolonies/coremod/network/messages/DecorationControllUpdateMessage.java b/src/main/java/com/minecolonies/coremod/network/messages/DecorationControllUpdateMessage.java new file mode 100644 index 00000000000..42faff80e7e --- /dev/null +++ b/src/main/java/com/minecolonies/coremod/network/messages/DecorationControllUpdateMessage.java @@ -0,0 +1,85 @@ +package com.minecolonies.coremod.network.messages; + +import com.minecolonies.api.util.BlockPosUtil; +import com.minecolonies.coremod.blocks.BlockDecorationController; +import com.minecolonies.coremod.tileentities.TileEntityDecorationController; +import io.netty.buffer.ByteBuf; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.Rotation; +import net.minecraft.util.math.BlockPos; +import net.minecraftforge.fml.common.network.ByteBufUtils; +import net.minecraftforge.fml.common.network.simpleimpl.IMessage; +import org.jetbrains.annotations.NotNull; + +/** + * Message to update the decoration control block. + */ +public class DecorationControllUpdateMessage extends AbstractMessage +{ + /** + * The position of the block. + */ + private BlockPos pos; + + /** + * The name to set. + */ + private String name; + + /** + * The level to set. + */ + private int level; + + /** + * Default constructor for forge + */ + public DecorationControllUpdateMessage() {super();} + + /** + * Constructor for the decoration controller update message. + * @param pos the position of the controller. + * @param name the name to set. + * @param level the new level to set. + */ + public DecorationControllUpdateMessage(@NotNull final BlockPos pos, final String name, final int level) + { + super(); + this.pos = pos; + this.name = name; + this.level = level; + } + + @Override + public void fromBytes(@NotNull final ByteBuf buf) + { + this.name = ByteBufUtils.readUTF8String(buf); + this.pos = BlockPosUtil.readFromByteBuf(buf); + this.level = buf.readInt(); + } + + @Override + public void toBytes(@NotNull final ByteBuf buf) + { + ByteBufUtils.writeUTF8String(buf, this.name); + BlockPosUtil.writeToByteBuf(buf, this.pos); + buf.writeInt(this.level); + } + + @Override + public void messageOnServerThread(final DecorationControllUpdateMessage message, final EntityPlayerMP player) + { + final TileEntity tileEntity = player.getServerWorld().getTileEntity(message.pos); + if (tileEntity instanceof TileEntityDecorationController) + { + final IBlockState state = player.getServerWorld().getBlockState(message.pos); + final EnumFacing basicFacing = state.getValue(BlockDecorationController.FACING); + ((TileEntityDecorationController) tileEntity).setSchematicName(message.name); + ((TileEntityDecorationController) tileEntity).setLevel(message.level); + ((TileEntityDecorationController) tileEntity).setBasicFacing(basicFacing); + } + } +} diff --git a/src/main/java/com/minecolonies/coremod/placementhandlers/MinecoloniesPlacementHandlers.java b/src/main/java/com/minecolonies/coremod/placementhandlers/MinecoloniesPlacementHandlers.java index b148f388aa1..f2d949489fb 100644 --- a/src/main/java/com/minecolonies/coremod/placementhandlers/MinecoloniesPlacementHandlers.java +++ b/src/main/java/com/minecolonies/coremod/placementhandlers/MinecoloniesPlacementHandlers.java @@ -1,5 +1,6 @@ package com.minecolonies.coremod.placementhandlers; +import com.ldtteam.structurize.util.PlacementSettings; import com.minecolonies.api.compatibility.candb.ChiselAndBitsCheck; import com.minecolonies.api.util.BlockUtils; import com.minecolonies.api.util.ItemStackUtils; @@ -260,7 +261,8 @@ public Object handle( @NotNull final IBlockState blockState, @Nullable final NBTTagCompound tileEntityData, final boolean complete, - final BlockPos centerPos) + final BlockPos centerPos, + final PlacementSettings settings) { if (world.getBlockState(pos).equals(blockState)) { @@ -274,7 +276,7 @@ public Object handle( if (tileEntityData != null) { - handleTileEntityPlacement(tileEntityData, world, pos); + handleTileEntityPlacement(tileEntityData, world, pos, settings); } return blockState; diff --git a/src/main/java/com/minecolonies/coremod/proxy/ClientProxy.java b/src/main/java/com/minecolonies/coremod/proxy/ClientProxy.java index bb30cf2abbf..cc995fac7a7 100644 --- a/src/main/java/com/minecolonies/coremod/proxy/ClientProxy.java +++ b/src/main/java/com/minecolonies/coremod/proxy/ClientProxy.java @@ -3,10 +3,7 @@ import com.minecolonies.api.util.Log; import com.minecolonies.api.util.constant.Constants; import com.minecolonies.coremod.blocks.ModBlocks; -import com.minecolonies.coremod.client.gui.WindowCitizen; -import com.minecolonies.coremod.client.gui.WindowClipBoard; -import com.minecolonies.coremod.client.gui.WindowMinecoloniesBuildTool; -import com.minecolonies.coremod.client.gui.WindowResourceList; +import com.minecolonies.coremod.client.gui.*; import com.minecolonies.coremod.client.render.*; import com.minecolonies.coremod.client.render.mobs.barbarians.RendererBarbarian; import com.minecolonies.coremod.client.render.mobs.barbarians.RendererChiefBarbarian; @@ -120,6 +117,18 @@ public void openBuildToolWindow(@Nullable final BlockPos pos) window.open(); } + @Override + public void openDecorationControllerWindow(@Nullable final BlockPos pos) + { + if (pos == null) + { + return; + } + + @Nullable final WindowDecorationController window = new WindowDecorationController(pos); + window.open(); + } + @Override public void openBuildToolWindow(final BlockPos pos, final String structureName, final int rotation, final WindowBuildTool.FreeMode mode) { @@ -201,6 +210,7 @@ public static void registerModels(@NotNull final ModelRegistryEvent event) createCustomModel(ModBlocks.blockRack); createCustomModel(ModBlocks.blockWayPoint); createCustomModel(ModBlocks.blockPostBox); + createCustomModel(ModBlocks.blockDecorationPlacerholder); createCustomModel(ModItems.clipboard); createCustomModel(ModItems.caliper); diff --git a/src/main/java/com/minecolonies/coremod/proxy/CommonProxy.java b/src/main/java/com/minecolonies/coremod/proxy/CommonProxy.java index 3d7eb80c297..3d237a63906 100644 --- a/src/main/java/com/minecolonies/coremod/proxy/CommonProxy.java +++ b/src/main/java/com/minecolonies/coremod/proxy/CommonProxy.java @@ -139,6 +139,7 @@ public void registerTileEntities() GameRegistry.registerTileEntity(TileEntityRack.class, new ResourceLocation(Constants.MOD_ID, "rack")); GameRegistry.registerTileEntity(TileEntityInfoPoster.class, new ResourceLocation(Constants.MOD_ID, "infoposter")); GameRegistry.registerTileEntity(TileEntityBarrel.class, new ResourceLocation(Constants.MOD_ID, "barrel")); + GameRegistry.registerTileEntity(TileEntityDecorationController.class, new ResourceLocation(Constants.MOD_ID, "decorationcontroller")); NetworkRegistry.INSTANCE.registerGuiHandler(MineColonies.instance, new GuiHandler()); } @@ -350,4 +351,12 @@ public RecipeBook getRecipeBookFromPlayer(@NotNull final EntityPlayer player) { return ((EntityPlayerMP) player).getRecipeBook(); } + + @Override + public void openDecorationControllerWindow(@NotNull final BlockPos pos) + { + /* + * Intentionally left empty. + */ + } } diff --git a/src/main/java/com/minecolonies/coremod/proxy/IProxy.java b/src/main/java/com/minecolonies/coremod/proxy/IProxy.java index 5c4c25fdd72..850ed0e4329 100644 --- a/src/main/java/com/minecolonies/coremod/proxy/IProxy.java +++ b/src/main/java/com/minecolonies/coremod/proxy/IProxy.java @@ -121,4 +121,10 @@ public interface IProxy */ @NotNull RecipeBook getRecipeBookFromPlayer(@NotNull final EntityPlayer player); + + /** + * Open the Window of the decoration controller. + * @param pos the position of the block. + */ + void openDecorationControllerWindow(@NotNull final BlockPos pos); } diff --git a/src/main/java/com/minecolonies/coremod/tileentities/ScarecrowTileEntity.java b/src/main/java/com/minecolonies/coremod/tileentities/ScarecrowTileEntity.java index 97d9584a9e2..f9aad48715f 100644 --- a/src/main/java/com/minecolonies/coremod/tileentities/ScarecrowTileEntity.java +++ b/src/main/java/com/minecolonies/coremod/tileentities/ScarecrowTileEntity.java @@ -405,7 +405,7 @@ public void setOwner(@NotNull final int ownerId) * @param ownerId the name of the citizen. * @param tempColony the colony view. */ - public void setOwner(@NotNull final int ownerId, final ColonyView tempColony) + public void setOwner(final int ownerId, final ColonyView tempColony) { this.ownerId = ownerId; if(tempColony != null) diff --git a/src/main/java/com/minecolonies/coremod/tileentities/TileEntityDecorationController.java b/src/main/java/com/minecolonies/coremod/tileentities/TileEntityDecorationController.java new file mode 100644 index 00000000000..6b85cd53de8 --- /dev/null +++ b/src/main/java/com/minecolonies/coremod/tileentities/TileEntityDecorationController.java @@ -0,0 +1,143 @@ +package com.minecolonies.coremod.tileentities; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.play.server.SPacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; +import org.jetbrains.annotations.NotNull; + +import javax.annotation.Nullable; + +import static com.minecolonies.api.util.constant.NbtTagConstants.*; + +public class TileEntityDecorationController extends TileEntity +{ + /** + * Tag to store the basic facing to NBT + */ + private static final String TAG_FACING = "facing"; + + /** + * The schematic name of the placerholder block. + */ + private String schematicName = ""; + + /** + * The current level. + */ + private int level = 0; + + /** + * The basic direction this block is facing. + */ + private EnumFacing basicFacing = EnumFacing.NORTH; + + /** + * Geter for the name stored in this. + * @return String name. + */ + public String getSchematicName() + { + return schematicName; + } + + /** + * Setter for the schematic name connected to this. + * @param schematicName the name to set. + */ + public void setSchematicName(final String schematicName) + { + this.schematicName = schematicName; + this.update(); + } + + /** + * Getter for the deco level associated. + * @return the level. + */ + public int getLevel() + { + return level; + } + + /** + * Set the deco level. + * @param level the max. + */ + public void setLevel(final int level) + { + this.level = level; + this.update(); + } + + /** + * Set the basic facing of this block. + * @param basicFacing the basic facing. + */ + public void setBasicFacing(final EnumFacing basicFacing) + { + this.basicFacing = basicFacing; + } + + /** + * Get the basic facing of the block. + * @return the basic facing. + */ + public EnumFacing getBasicFacing() + { + return basicFacing; + } + + /** + * Trigger update action. + */ + private void update() + { + this.markDirty(); + final IBlockState state = world.getBlockState(pos); + world.notifyBlockUpdate(pos, state, state, 0x03); + } + + @Override + public void readFromNBT(final NBTTagCompound compound) + { + super.readFromNBT(compound); + this.schematicName = compound.getString(TAG_NAME); + this.level = compound.getInteger(TAG_LEVEL); + this.basicFacing = EnumFacing.byHorizontalIndex(compound.getInteger(TAG_FACING)); + } + + @NotNull + @Override + public NBTTagCompound writeToNBT(final NBTTagCompound compound) + { + super.writeToNBT(compound); + compound.setString(TAG_NAME, schematicName); + compound.setInteger(TAG_LEVEL, level); + compound.setInteger(TAG_FACING, basicFacing.getHorizontalIndex()); + return compound; + } + + @Nullable + @Override + public SPacketUpdateTileEntity getUpdatePacket() + { + return new SPacketUpdateTileEntity(this.pos, 0x9, this.getUpdateTag()); + } + + @NotNull + @Override + public NBTTagCompound getUpdateTag() + { + return this.writeToNBT(new NBTTagCompound()); + } + + @Override + public void onDataPacket(final NetworkManager net, final SPacketUpdateTileEntity packet) + { + final NBTTagCompound compound = packet.getNbtCompound(); + this.readFromNBT(compound); + } +} diff --git a/src/main/java/com/minecolonies/coremod/util/InstantStructurePlacer.java b/src/main/java/com/minecolonies/coremod/util/InstantStructurePlacer.java index 5b7e47c6640..5780fad5749 100644 --- a/src/main/java/com/minecolonies/coremod/util/InstantStructurePlacer.java +++ b/src/main/java/com/minecolonies/coremod/util/InstantStructurePlacer.java @@ -62,6 +62,7 @@ public static void loadAndPlaceStructureWithRotation( @NotNull final InstantStructurePlacer structureWrapper = new InstantStructurePlacer(worldObj, name); structureWrapper.structure.setPosition(pos); structureWrapper.rotate(rotations, worldObj, pos, mirror); + structureWrapper.structure.setPlacementSettings(new PlacementSettings(mirror, BlockPosUtil.getRotationFromRotations(rotations))); structureWrapper.placeStructure(pos.subtract(structureWrapper.structure.getOffset()), complete); } catch (final IllegalStateException e) @@ -169,7 +170,7 @@ private void handleBlockPlacement(final BlockPos pos, final IBlockState localSta { if (handlers.canHandle(world, pos, localState)) { - final Object result = handlers.handle(world, pos, localState, tileEntityData, complete, structure.getLocalPosition()); + final Object result = handlers.handle(world, pos, localState, tileEntityData, complete, structure.getLocalPosition(), structure.getSettings()); if (result instanceof IBlockState) { final IBlockState blockState = (IBlockState) result; diff --git a/src/main/resources/assets/minecolonies/blockstates/barrel_block.json b/src/main/resources/assets/minecolonies/blockstates/barrel_block.json index 9bc7080ea22..67cd1fbf4a2 100644 --- a/src/main/resources/assets/minecolonies/blockstates/barrel_block.json +++ b/src/main/resources/assets/minecolonies/blockstates/barrel_block.json @@ -21,4 +21,4 @@ "done": { "model": "minecolonies:barrel_block/100perc_crate"} } } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/minecolonies/blockstates/decorationcontroller.json b/src/main/resources/assets/minecolonies/blockstates/decorationcontroller.json new file mode 100644 index 00000000000..e1dca714399 --- /dev/null +++ b/src/main/resources/assets/minecolonies/blockstates/decorationcontroller.json @@ -0,0 +1,19 @@ +{ + "forge_marker": 1, + "defaults": { + "model": "minecolonies:decorationcontroller" + }, + "variants": + { + "facing": { + "east": {"uvlock": true, "x": 90, "y": 90}, + "south": {"uvlock": true, "x": 90, "y": 180}, + "west": {"uvlock": true, "x": 90, "y": 270 }, + "north": {"uvlock": true, "x": 90 } + }, + "mirror": { + "true": {}, + "false": {} + } + } +} diff --git a/src/main/resources/assets/minecolonies/gui/windowdecorationcontroller.xml b/src/main/resources/assets/minecolonies/gui/windowdecorationcontroller.xml new file mode 100644 index 00000000000..678c2889f94 --- /dev/null +++ b/src/main/resources/assets/minecolonies/gui/windowdecorationcontroller.xml @@ -0,0 +1,24 @@ + + \ No newline at end of file diff --git a/src/main/resources/assets/minecolonies/lang/en_us.lang b/src/main/resources/assets/minecolonies/lang/en_us.lang index 21cc7548929..e4ef1c1e956 100644 --- a/src/main/resources/assets/minecolonies/lang/en_us.lang +++ b/src/main/resources/assets/minecolonies/lang/en_us.lang @@ -925,4 +925,9 @@ com.minecolonies.coremod.gui.buildinghiremode=Building Hiring Mode: com.minecolonies.coremod.gui.hiringmode.default=Default (Colony override) com.minecolonies.coremod.gui.hiringmode.auto=Automatic com.minecolonies.coremod.gui.hiringmode.manual=Manual -com.minecolonies.coremod.gui.name.tooLong=We reduced the string to "%s" since it exceeded the limit of 15 letters. \ No newline at end of file +com.minecolonies.coremod.gui.name.tooLong=We reduced the string to "%s" since it exceeded the limit of 15 letters. + +tile.minecolonies.decorationcontroller.name=Decoration Controller +com.minecolonies.coremod.gui.deco.namescan=Final file path and filename, no level: +com.minecolonies.coremod.gui.deco.name=The name of the decoration: +com.minecolonies.coremod.gui.deco.level=The level of the decoration: \ No newline at end of file diff --git a/src/main/resources/assets/minecolonies/models/block/decorationcontroller.json b/src/main/resources/assets/minecolonies/models/block/decorationcontroller.json new file mode 100644 index 00000000000..c24871dbc2b --- /dev/null +++ b/src/main/resources/assets/minecolonies/models/block/decorationcontroller.json @@ -0,0 +1,43 @@ +{ + "credit": "Made with Blockbench", + "textures": { + "13": "blocks/quartz_block_bottom", + "1_2": "blocks/cauldron_inner", + "particle": "blocks/quartz_block_bottom" + }, + "elements": [ + { + "name": "Charcoal", + "from": [4.8, 0.05, 5.5], + "to": [5.05, 0.3, 7], + "rotation": {"angle": 22.5, "axis": "y", "origin": [8.3, 8, 2]}, + "faces": { + "north": {"uv": [0, 0, 0.25, 0.25], "texture": "#1_2"}, + "east": {"uv": [0, 0, 1.5, 0.25], "texture": "#1_2"}, + "south": {"uv": [0, 0, 0.25, 0.25], "texture": "#1_2"}, + "west": {"uv": [0, 0, 1.5, 0.25], "texture": "#1_2"}, + "up": {"uv": [0, 0, 0.25, 1.5], "texture": "#1_2"}, + "down": {"uv": [0, 0, 0.25, 1.5], "texture": "#1_2"} + } + }, + { + "name": "Paper", + "from": [6.3, 0, 6], + "to": [9.55, 0.05, 10], + "faces": { + "north": {"uv": [0, 0, 3.25, 0.05], "texture": "#13"}, + "east": {"uv": [0, 0, 4, 0.05], "texture": "#13"}, + "south": {"uv": [0, 0, 3.25, 0.05], "texture": "#13"}, + "west": {"uv": [0, 0, 4, 0.05], "texture": "#13"}, + "up": {"uv": [0, 0, 16, 16], "rotation": 90, "texture": "#13"}, + "down": {"uv": [0, 0, 16, 16], "rotation": 270, "texture": "#13"} + } + } + ], + "groups": [ + { + "name": "WritingSet-charcoal", + "children": [0, 1] + } + ] +} diff --git a/src/main/resources/assets/minecolonies/models/item/barrel_block.json b/src/main/resources/assets/minecolonies/models/item/barrel_block.json index a8f11c92d2e..6598636998e 100644 --- a/src/main/resources/assets/minecolonies/models/item/barrel_block.json +++ b/src/main/resources/assets/minecolonies/models/item/barrel_block.json @@ -1,41 +1,124 @@ { "parent": "minecolonies:block/barrel_block/0perc_crate", "display": { - "gui": { - "rotation": [45, 170, 0], - "translation": [0, 0, 0], - "scale": [0.6, 0.5, 0.6] - }, - "thirdperson_lefthand": { - "rotation": [30, 40, 0], - "translation": [0, 0, 0], - "scale": [0.5, 0.5, 0.5] - }, - "thirdperson_righthand": { - "rotation": [30, 40, 0], - "translation": [0, 0, 0], - "scale": [0.5, 0.5, 0.5] - }, - "firstperson_lefthand": { - "rotation": [0, 0, 0], - "translation": [0, 0, 0], - "scale": [0.3, 0.3, 0.3] - }, - "firstperson_righthand": { - "rotation": [0, 0, 0], - "translation": [0, 0, 0], - "scale": [0.3, 0.3, 0.3] - }, - "ground": { - "rotation": [0, 0, 0], - "translation": [0, 0, 0], - "scale": [0.3, 0.3, 0.3] - }, - "fixed": { - "rotation": [0, 180, 45], - "translation": [-3, -3, -2], - "scale": [0.5, 0.5, 0.5] - } + "gui": { + "rotation": [ + 45, + 170, + 0 + ], + "translation": [ + 0, + 0, + 0 + ], + "scale": [ + 0.6, + 0.5, + 0.6 + ] + }, + "thirdperson_lefthand": { + "rotation": [ + 30, + 40, + 0 + ], + "translation": [ + 0, + 0, + 0 + ], + "scale": [ + 0.5, + 0.5, + 0.5 + ] + }, + "thirdperson_righthand": { + "rotation": [ + 30, + 40, + 0 + ], + "translation": [ + 0, + 0, + 0 + ], + "scale": [ + 0.5, + 0.5, + 0.5 + ] + }, + "firstperson_lefthand": { + "rotation": [ + 0, + 0, + 0 + ], + "translation": [ + 0, + 0, + 0 + ], + "scale": [ + 0.3, + 0.3, + 0.3 + ] + }, + "firstperson_righthand": { + "rotation": [ + 0, + 0, + 0 + ], + "translation": [ + 0, + 0, + 0 + ], + "scale": [ + 0.3, + 0.3, + 0.3 + ] + }, + "ground": { + "rotation": [ + 0, + 0, + 0 + ], + "translation": [ + 0, + 0, + 0 + ], + "scale": [ + 0.3, + 0.3, + 0.3 + ] + }, + "fixed": { + "rotation": [ + 0, + 180, + 45 + ], + "translation": [ + -3, + -3, + -2 + ], + "scale": [ + 0.5, + 0.5, + 0.5 + ] } } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/minecolonies/models/item/compost.json b/src/main/resources/assets/minecolonies/models/item/compost.json index 47326090abd..6a383df16dd 100644 --- a/src/main/resources/assets/minecolonies/models/item/compost.json +++ b/src/main/resources/assets/minecolonies/models/item/compost.json @@ -31,4 +31,3 @@ } } } -} \ No newline at end of file diff --git a/src/main/resources/assets/minecolonies/models/item/decorationcontroller.json b/src/main/resources/assets/minecolonies/models/item/decorationcontroller.json new file mode 100644 index 00000000000..a1b8518f362 --- /dev/null +++ b/src/main/resources/assets/minecolonies/models/item/decorationcontroller.json @@ -0,0 +1,124 @@ +{ + "parent": "minecolonies:block/decorationcontroller", + "display": { + "gui": { + "rotation": [ + 90, + 0, + 0 + ], + "translation": [ + 0, + 2, + 0 + ], + "scale": [ + 2, + 2, + 2 + ] + }, + "thirdperson_lefthand": { + "rotation": [ + 30, + 40, + 0 + ], + "translation": [ + 0, + 0, + 0 + ], + "scale": [ + 0.5, + 0.5, + 0.5 + ] + }, + "thirdperson_righthand": { + "rotation": [ + 30, + 40, + 0 + ], + "translation": [ + 0, + 0, + 0 + ], + "scale": [ + 0.5, + 0.5, + 0.5 + ] + }, + "firstperson_lefthand": { + "rotation": [ + 0, + 0, + 0 + ], + "translation": [ + 0, + 0, + 0 + ], + "scale": [ + 0.3, + 0.3, + 0.3 + ] + }, + "firstperson_righthand": { + "rotation": [ + 0, + 0, + 0 + ], + "translation": [ + 0, + 0, + 0 + ], + "scale": [ + 0.3, + 0.3, + 0.3 + ] + }, + "ground": { + "rotation": [ + 0, + 0, + 0 + ], + "translation": [ + 0, + 0, + 0 + ], + "scale": [ + 0.3, + 0.3, + 0.3 + ] + }, + "fixed": { + "rotation": [ + 0, + 180, + 45 + ], + "translation": [ + -3, + -3, + -2 + ], + "scale": [ + 0.5, + 0.5, + 0.5 + ] + } + } +} diff --git a/src/main/resources/assets/minecolonies/schematics/Acacia/Cowoby4.blueprint b/src/main/resources/assets/minecolonies/schematics/Acacia/Cowoby4.blueprint deleted file mode 100644 index c20d19f0d94..00000000000 Binary files a/src/main/resources/assets/minecolonies/schematics/Acacia/Cowoby4.blueprint and /dev/null differ diff --git a/src/main/resources/assets/minecolonies/schematics/Medieval Spruce/Buider3.blueprint b/src/main/resources/assets/minecolonies/schematics/Medieval Spruce/Buider3.blueprint deleted file mode 100644 index 69a7935faa7..00000000000 Binary files a/src/main/resources/assets/minecolonies/schematics/Medieval Spruce/Buider3.blueprint and /dev/null differ diff --git a/src/main/resources/assets/minecolonies/schematics/SpaceWars/Sifter1.blueprint b/src/main/resources/assets/minecolonies/schematics/SpaceWars/Sifter1.blueprint new file mode 100644 index 00000000000..c366f6f6221 Binary files /dev/null and b/src/main/resources/assets/minecolonies/schematics/SpaceWars/Sifter1.blueprint differ diff --git a/src/main/resources/assets/minecolonies/schematics/SpaceWars/Sifter2.blueprint b/src/main/resources/assets/minecolonies/schematics/SpaceWars/Sifter2.blueprint new file mode 100644 index 00000000000..14ac00bd0df Binary files /dev/null and b/src/main/resources/assets/minecolonies/schematics/SpaceWars/Sifter2.blueprint differ diff --git a/src/main/resources/assets/minecolonies/schematics/SpaceWars/Sifter3.blueprint b/src/main/resources/assets/minecolonies/schematics/SpaceWars/Sifter3.blueprint new file mode 100644 index 00000000000..fdf225d5e75 Binary files /dev/null and b/src/main/resources/assets/minecolonies/schematics/SpaceWars/Sifter3.blueprint differ diff --git a/src/main/resources/assets/minecolonies/schematics/SpaceWars/Sifter4.blueprint b/src/main/resources/assets/minecolonies/schematics/SpaceWars/Sifter4.blueprint new file mode 100644 index 00000000000..1e96b017251 Binary files /dev/null and b/src/main/resources/assets/minecolonies/schematics/SpaceWars/Sifter4.blueprint differ diff --git a/src/main/resources/assets/minecolonies/schematics/SpaceWars/Sifter5.blueprint b/src/main/resources/assets/minecolonies/schematics/SpaceWars/Sifter5.blueprint new file mode 100644 index 00000000000..2a6396c4363 Binary files /dev/null and b/src/main/resources/assets/minecolonies/schematics/SpaceWars/Sifter5.blueprint differ