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
This commit is contained in:
simibubi 2019-07-17 21:48:56 +02:00
parent 976b7c5bea
commit ebb9d6e490
17 changed files with 273 additions and 25 deletions

View file

@ -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<BlockPos, BlockState> 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),

View file

@ -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);

View file

@ -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());

View file

@ -3,7 +3,7 @@
"textures": {
"0": "block/white_stained_glass",
"1": "block/obsidian",
"2": "block/blue_terracotta"
"2": "block/light_blue_concrete_powder"
},
"elements": [
{

View file

@ -3,7 +3,7 @@
"textures": {
"0": "block/white_stained_glass",
"1": "block/obsidian",
"2": "block/blue_terracotta"
"2": "block/light_blue_concrete_powder"
},
"elements": [
{

View file

@ -3,7 +3,7 @@
"textures": {
"0": "block/white_stained_glass",
"1": "block/obsidian",
"2": "block/blue_terracotta"
"2": "block/light_blue_concrete_powder"
},
"elements": [
{

View file

@ -3,7 +3,7 @@
"textures": {
"0": "block/white_stained_glass",
"1": "block/obsidian",
"2": "block/blue_terracotta"
"2": "block/light_blue_concrete_powder"
},
"elements": [
{

View file

@ -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": [

Binary file not shown.

Before

Width:  |  Height:  |  Size: 352 B

After

Width:  |  Height:  |  Size: 356 B

View file

@ -0,0 +1,20 @@
{
"type": "minecraft:block",
"pools": [
{
"name": "create:schematic_table",
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "create:schematic_table"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View file

@ -0,0 +1,20 @@
{
"type": "minecraft:block",
"pools": [
{
"name": "create:schematicannon",
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "create:schematicannon"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View file

@ -0,0 +1,15 @@
{
"type": "crafting_shapeless",
"ingredients": [
{
"item": "create:empty_blueprint"
},
{
"item": "minecraft:feather"
}
],
"result": {
"item": "create:blueprint_and_quill",
"count": 1
}
}

View file

@ -0,0 +1,15 @@
{
"type": "crafting_shapeless",
"ingredients": [
{
"item": "minecraft:paper"
},
{
"item": "minecraft:light_blue_dye"
}
],
"result": {
"item": "create:empty_blueprint",
"count": 1
}
}

View file

@ -0,0 +1,20 @@
{
"type": "crafting_shaped",
"pattern": [
"WWW",
" S ",
" S "
],
"key": {
"W": {
"tag": "minecraft:wooden_slabs"
},
"S": {
"item": "minecraft:smooth_stone"
}
},
"result": {
"item": "create:schematic_table",
"count": 1
}
}

View file

@ -0,0 +1,29 @@
{
"type": "crafting_shaped",
"pattern": [
" C ",
"LDL",
"SIS"
],
"key": {
"I": {
"item": "minecraft:iron_block"
},
"D": {
"item": "minecraft:dispenser"
},
"L": {
"tag": "minecraft:logs"
},
"S": {
"item": "minecraft:smooth_stone_slab"
},
"C": {
"item": "minecraft:cauldron"
}
},
"result": {
"item": "create:schematicannon",
"count": 1
}
}

View file

@ -0,0 +1,29 @@
{
"type": "crafting_shaped",
"pattern": [
" GB",
"LEG",
"OL "
],
"key": {
"B": {
"item": "minecraft:dark_oak_button"
},
"E": {
"item": "minecraft:end_rod"
},
"L": {
"item": "minecraft:light_blue_dye"
},
"O": {
"item": "minecraft:obsidian"
},
"G": {
"item": "minecraft:white_stained_glass_pane"
}
},
"result": {
"item": "create:symmetry_wand",
"count": 1
}
}

View file

@ -0,0 +1,21 @@
{
"type": "crafting_shapeless",
"ingredients": [
{
"item": "minecraft:horn_coral"
},
{
"item": "minecraft:bone_meal"
},
{
"tag": "minecraft:small_flowers"
},
{
"tag": "minecraft:small_flowers"
}
],
"result": {
"item": "create:tree_fertilizer",
"count": 2
}
}