From ebb9d6e4903e54fbbe0e87661e89ac8fdf7b13ab Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Wed, 17 Jul 2019 21:48:56 +0200 Subject: [PATCH] Survival Proofing - Fixed Symmetry Wand not using Blocks from the inventory - Symmetry Wand now drops blocks in the position of the block broken by hand - Added recipes for all craftables - Added loot tables for all breakables - Made Tree Fertilizer texture less unnatural --- .../create/item/ItemWandSymmetry.java | 48 +++++++++++++++-- .../simibubi/create/item/SymmetryHandler.java | 19 ++++--- .../create/schematic/BlueprintHandler.java | 50 +++++++++++++++--- .../models/block/symmetry_crossplane.json | 2 +- .../block/symmetry_crossplane_diagonal.json | 2 +- .../create/models/block/symmetry_plane.json | 2 +- .../models/block/symmetry_tripleplane.json | 2 +- .../create/models/item/symmetry_wand.json | 4 +- .../create/textures/item/tree_fertilizer.png | Bin 352 -> 356 bytes .../loot_tables/blocks/schematic_table.json | 20 +++++++ .../loot_tables/blocks/schematicannon.json | 20 +++++++ .../create/recipes/blueprint_and_quill.json | 15 ++++++ .../data/create/recipes/empty_blueprint.json | 15 ++++++ .../data/create/recipes/schematic_table.json | 20 +++++++ .../data/create/recipes/schematicannon.json | 29 ++++++++++ .../data/create/recipes/symmetry_wand.json | 29 ++++++++++ .../data/create/recipes/tree_fertilizer.json | 21 ++++++++ 17 files changed, 273 insertions(+), 25 deletions(-) create mode 100644 src/main/resources/data/create/loot_tables/blocks/schematic_table.json create mode 100644 src/main/resources/data/create/loot_tables/blocks/schematicannon.json create mode 100644 src/main/resources/data/create/recipes/blueprint_and_quill.json create mode 100644 src/main/resources/data/create/recipes/empty_blueprint.json create mode 100644 src/main/resources/data/create/recipes/schematic_table.json create mode 100644 src/main/resources/data/create/recipes/schematicannon.json create mode 100644 src/main/resources/data/create/recipes/symmetry_wand.json create mode 100644 src/main/resources/data/create/recipes/tree_fertilizer.json diff --git a/src/main/java/com/simibubi/create/item/ItemWandSymmetry.java b/src/main/java/com/simibubi/create/item/ItemWandSymmetry.java index 0c2608c62..8873afb8b 100644 --- a/src/main/java/com/simibubi/create/item/ItemWandSymmetry.java +++ b/src/main/java/com/simibubi/create/item/ItemWandSymmetry.java @@ -14,13 +14,16 @@ import com.simibubi.create.item.symmetry.SymmetryPlane; import com.simibubi.create.networking.PacketSymmetryEffect; import com.simibubi.create.networking.Packets; +import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.BlockItem; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; import net.minecraft.nbt.CompoundNBT; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; @@ -144,6 +147,8 @@ public class ItemWandSymmetry extends Item { checkNBT(wand); if (!isEnabled(wand)) return; + if (!BlockItem.BLOCK_TO_ITEM.containsKey(block.getBlock())) + return; Map blockSet = new HashMap<>(); blockSet.put(pos, block); @@ -161,8 +166,24 @@ public class ItemWandSymmetry extends Item { targets.add(pos); for (BlockPos position : blockSet.keySet()) { if (world.func_217350_a(block, position, ISelectionContext.forEntity(player))) { - world.setBlockState(position, blockSet.get(position)); - targets.add(position); + Item required = BlockItem.BLOCK_TO_ITEM.get(block.getBlock()); + + if (player.isCreative()) { + world.setBlockState(position, blockSet.get(position)); + targets.add(position); + continue; + } + + for (int i = 0; i < player.inventory.getSizeInventory(); ++i) { + ItemStack itemstack = player.inventory.getStackInSlot(i); + if (itemstack.getItem() == required && itemstack.getCount() > 0) { + player.inventory.setInventorySlotContents(i, + new ItemStack(itemstack.getItem(), itemstack.getCount() - 1)); + world.setBlockState(position, blockSet.get(position)); + targets.add(position); + break; + } + } } } @@ -172,6 +193,7 @@ public class ItemWandSymmetry extends Item { public static void remove(World world, ItemStack wand, PlayerEntity player, BlockPos pos) { BlockState air = Blocks.AIR.getDefaultState(); + BlockState ogBlock = world.getBlockState(pos); checkNBT(wand); if (!isEnabled(wand)) return; @@ -191,8 +213,26 @@ public class ItemWandSymmetry extends Item { targets.add(pos); for (BlockPos position : blockSet.keySet()) { - targets.add(position); - world.setBlockState(position, air); + if (!player.isCreative() && ogBlock.getBlock() != world.getBlockState(position).getBlock()) + continue; + if (position.equals(pos)) + continue; + + BlockState blockstate = world.getBlockState(position); + if (blockstate.isAir(world, position)) { + continue; + } else { + targets.add(position); + world.playEvent(2001, pos, Block.getStateId(blockstate)); + world.setBlockState(position, air, 3); + + if (!player.isCreative()) { + if (!player.getHeldItemMainhand().isEmpty()) + player.getHeldItemMainhand().onBlockDestroyed(world, blockstate, position, player); + TileEntity tileentity = blockstate.hasTileEntity() ? world.getTileEntity(position) : null; + Block.spawnDrops(blockstate, world, pos, tileentity); + } + } } Packets.channel.send(PacketDistributor.TRACKING_ENTITY_AND_SELF.with(() -> player), diff --git a/src/main/java/com/simibubi/create/item/SymmetryHandler.java b/src/main/java/com/simibubi/create/item/SymmetryHandler.java index ae9d13064..67e025332 100644 --- a/src/main/java/com/simibubi/create/item/SymmetryHandler.java +++ b/src/main/java/com/simibubi/create/item/SymmetryHandler.java @@ -19,6 +19,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.ItemStack; import net.minecraft.particles.ParticleTypes; +import net.minecraft.particles.RedstoneParticleData; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; @@ -60,7 +61,7 @@ public class SymmetryHandler { public static void onBlockDestroyed(BreakEvent event) { if (event.getWorld().isRemote()) return; - + PlayerEntity player = event.getPlayer(); PlayerInventory inv = player.inventory; for (int i = 0; i < PlayerInventory.getHotbarSize(); i++) { @@ -97,8 +98,8 @@ public class SymmetryHandler { buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); GlStateManager.pushMatrix(); GlStateManager.translated(0, yShift + .2f, 0); - mc.getBlockRendererDispatcher().renderBlock(mirror.getModel(), pos, player.world, buffer, player.world.getRandom(), - EmptyModelData.INSTANCE); + mc.getBlockRendererDispatcher().renderBlock(mirror.getModel(), pos, player.world, buffer, + player.world.getRandom(), EmptyModelData.INSTANCE); Tessellator.getInstance().draw(); GlStateManager.popMatrix(); TessellatorHelper.cleanUpAfterDrawing(); @@ -147,7 +148,7 @@ public class SymmetryHandler { } public static void drawEffect(BlockPos from, BlockPos to) { - double density = 0.3f; + double density = 0.8f; Vec3d start = new Vec3d(from).add(0.5, 0.5, 0.5); Vec3d end = new Vec3d(to).add(0.5, 0.5, 0.5); Vec3d diff = end.subtract(start); @@ -156,15 +157,17 @@ public class SymmetryHandler { int steps = (int) (diff.length() / step.length()); Random r = new Random(); - for (int i = 5; i < steps - 1; i++) { + for (int i = 3; i < steps - 1; i++) { Vec3d pos = start.add(step.scale(i)); Vec3d speed = new Vec3d(0, r.nextDouble() * -40f, 0); - Minecraft.getInstance().world.addParticle(ParticleTypes.WITCH, pos.x, pos.y, pos.z, speed.x, - speed.y, speed.z); + + Minecraft.getInstance().world.addParticle( + new RedstoneParticleData(1, 1, 1, 1), + pos.x, pos.y, pos.z, speed.x, speed.y, speed.z); } Vec3d speed = new Vec3d(0, r.nextDouble() * 1 / 32f, 0); - Vec3d pos = start.add(step.scale(5)); + Vec3d pos = start.add(step.scale(2)); Minecraft.getInstance().world.addParticle(ParticleTypes.END_ROD, pos.x, pos.y, pos.z, speed.x, speed.y, speed.z); diff --git a/src/main/java/com/simibubi/create/schematic/BlueprintHandler.java b/src/main/java/com/simibubi/create/schematic/BlueprintHandler.java index 2bfc1190e..2170d9a7f 100644 --- a/src/main/java/com/simibubi/create/schematic/BlueprintHandler.java +++ b/src/main/java/com/simibubi/create/schematic/BlueprintHandler.java @@ -5,6 +5,7 @@ import java.util.HashMap; import org.lwjgl.glfw.GLFW; import com.google.common.collect.ImmutableList; +import com.simibubi.create.AllBlocks; import com.simibubi.create.AllItems; import com.simibubi.create.Create; import com.simibubi.create.gui.BlueprintHotbarOverlay; @@ -20,10 +21,12 @@ import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.NBTUtil; import net.minecraft.util.Direction.Axis; import net.minecraft.util.Mirror; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.StringTextComponent; @@ -37,6 +40,8 @@ import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; +import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; +import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemPickupEvent; import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent; @EventBusSubscriber(value = Dist.CLIENT, bus = Bus.FORGE) @@ -70,6 +75,38 @@ public class BlueprintHandler { selectionScreen = new ToolSelectionScreen(ImmutableList.of(Tools.Deploy), this::equip); } + @SubscribeEvent + public static void onPaperCrafted(ItemCraftedEvent event) { + if (event.isCanceled()) + return; + if (event.getCrafting().getItem() == Items.PAPER) { + event.getPlayer() + .unlockRecipes(new ResourceLocation[] { AllItems.EMPTY_BLUEPRINT.get().getRegistryName() }); + } + if (event.getCrafting().getItem() == Items.BONE_MEAL) { + event.getPlayer() + .unlockRecipes(new ResourceLocation[] { AllItems.TREE_FERTILIZER.get().getRegistryName() }); + } + if (event.getCrafting().getItem() == Items.END_ROD) { + event.getPlayer().unlockRecipes(new ResourceLocation[] { AllItems.SYMMETRY_WAND.get().getRegistryName() }); + } + if (AllItems.EMPTY_BLUEPRINT.typeOf(event.getCrafting())) { + event.getPlayer() + .unlockRecipes(new ResourceLocation[] { AllItems.BLUEPRINT_AND_QUILL.get().getRegistryName(), + AllBlocks.SCHEMATIC_TABLE.get().getRegistryName(), + AllBlocks.SCHEMATICANNON.get().getRegistryName() }); + } + } + + @SubscribeEvent + public static void onItemPickup(ItemPickupEvent event) { + if (event.isCanceled()) + return; + if (event.getStack().getItem() == Items.END_ROD) { + event.getPlayer().unlockRecipes(new ResourceLocation[] { AllItems.SYMMETRY_WAND.get().getRegistryName() }); + } + } + @SubscribeEvent public static void onClientTick(ClientTickEvent event) { ClientPlayerEntity player = Minecraft.getInstance().player; @@ -100,9 +137,8 @@ public class BlueprintHandler { if (toolBefore != null) { instance.selectionScreen.setSelectedElement(toolBefore); instance.equip(toolBefore); - } - } - else + } + } else instance.selectionScreen = new ToolSelectionScreen(ImmutableList.of(Tools.Deploy), instance::equip); instance.sync(); } @@ -229,10 +265,10 @@ public class BlueprintHandler { if (deployed) { Template schematic = ItemBlueprint.getSchematic(item); - + if (schematic.getSize().equals(BlockPos.ZERO)) return; - + SchematicWorld w = new SchematicWorld(new HashMap<>(), new Cuboid(), anchor); PlacementSettings settings = cachedSettings.copy(); settings.setBoundingBox(null); @@ -317,13 +353,13 @@ public class BlueprintHandler { markDirty(); } - + public void setMirror(Mirror mirror) { cachedSettings.setMirror(mirror); item.getTag().putString("Mirror", cachedSettings.getMirror().name()); markDirty(); } - + public void setRotation(Rotation rotation) { cachedSettings.setRotation(rotation); item.getTag().putString("Rotation", cachedSettings.getRotation().name()); diff --git a/src/main/resources/assets/create/models/block/symmetry_crossplane.json b/src/main/resources/assets/create/models/block/symmetry_crossplane.json index 4e221b354..ba4f5ca74 100644 --- a/src/main/resources/assets/create/models/block/symmetry_crossplane.json +++ b/src/main/resources/assets/create/models/block/symmetry_crossplane.json @@ -3,7 +3,7 @@ "textures": { "0": "block/white_stained_glass", "1": "block/obsidian", - "2": "block/blue_terracotta" + "2": "block/light_blue_concrete_powder" }, "elements": [ { diff --git a/src/main/resources/assets/create/models/block/symmetry_crossplane_diagonal.json b/src/main/resources/assets/create/models/block/symmetry_crossplane_diagonal.json index 431ff819b..38dd61dcc 100644 --- a/src/main/resources/assets/create/models/block/symmetry_crossplane_diagonal.json +++ b/src/main/resources/assets/create/models/block/symmetry_crossplane_diagonal.json @@ -3,7 +3,7 @@ "textures": { "0": "block/white_stained_glass", "1": "block/obsidian", - "2": "block/blue_terracotta" + "2": "block/light_blue_concrete_powder" }, "elements": [ { diff --git a/src/main/resources/assets/create/models/block/symmetry_plane.json b/src/main/resources/assets/create/models/block/symmetry_plane.json index 6b4c451ce..816212543 100644 --- a/src/main/resources/assets/create/models/block/symmetry_plane.json +++ b/src/main/resources/assets/create/models/block/symmetry_plane.json @@ -3,7 +3,7 @@ "textures": { "0": "block/white_stained_glass", "1": "block/obsidian", - "2": "block/blue_terracotta" + "2": "block/light_blue_concrete_powder" }, "elements": [ { diff --git a/src/main/resources/assets/create/models/block/symmetry_tripleplane.json b/src/main/resources/assets/create/models/block/symmetry_tripleplane.json index e29c91958..af46c8584 100644 --- a/src/main/resources/assets/create/models/block/symmetry_tripleplane.json +++ b/src/main/resources/assets/create/models/block/symmetry_tripleplane.json @@ -3,7 +3,7 @@ "textures": { "0": "block/white_stained_glass", "1": "block/obsidian", - "2": "block/blue_terracotta" + "2": "block/light_blue_concrete_powder" }, "elements": [ { diff --git a/src/main/resources/assets/create/models/item/symmetry_wand.json b/src/main/resources/assets/create/models/item/symmetry_wand.json index 29b7719ff..d70df1b4d 100644 --- a/src/main/resources/assets/create/models/item/symmetry_wand.json +++ b/src/main/resources/assets/create/models/item/symmetry_wand.json @@ -30,10 +30,10 @@ }, "textures": { "0": "block/obsidian", - "1": "block/purple_concrete_powder", + "1": "block/light_blue_concrete_powder", "2": "block/dark_oak_log", "3": "block/white_stained_glass", - "4": "block/purple_stained_glass", + "4": "block/light_blue_stained_glass", "5": "block/white_concrete" }, "elements": [ diff --git a/src/main/resources/assets/create/textures/item/tree_fertilizer.png b/src/main/resources/assets/create/textures/item/tree_fertilizer.png index 93250c764750d91fc7124311657f38d7ca0fa2c7..98d2f982a36610836e98b90f5c92b5524ed6460c 100644 GIT binary patch delta 242 zcmVJe`!Dgk!wZXfTn2_avjX68(w|_hi0OhFawf_)!+Zb>NJ@Ns=gWa sECDhC6hN$nB{eo`F80^kCWdVkSLL_t(IPtA}q4gpaRhF_~uQYcjPB-}zn!Vw4>9T#v2&Oyl; zTxiFBFZ0`#WwS)#PbM?(&3ylx-SGcvZ(2m+$Is-jO;2MZS2A)aAzP~1d19-}{EZ2NA-Cfg$$G%Y`Y7CGJ2ZvtlJ7=1~h!=nqT3vmIpEpob zFJQtZGQ)&g=a&XF5Vcn14ydzj#9DzleaEv;AQ&cV2s0p=c>n!R%)cfxLHRq!iV`3r oKmp`ZSkhpn;q