Build works. Added synergy of randomizer bag with mirror/array. Mirror slabs vertically.
This commit is contained in:
@@ -49,10 +49,7 @@ public class Array {
|
||||
IItemHandler bagInventory = null;
|
||||
if (event.getPlayer().getHeldItemMainhand().getItem() instanceof ItemRandomizerBag) {
|
||||
bagInventory = ItemRandomizerBag.getBagInventory(event.getPlayer().getHeldItemMainhand());
|
||||
//EffortlessBuilding.log(event.getPlayer(), "placed with bag");
|
||||
}
|
||||
//EffortlessBuilding.log(event.getPlayer(), event.getPlayer().getHeldItem(event.getHand()).getDisplayName());
|
||||
//TODO fix not recognizing its the bag in singleplayer and now in multiplayer too?
|
||||
|
||||
for (int i = 0; i < a.count; i++) {
|
||||
pos = pos.add(offset);
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package nl.requios.effortlessbuilding;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDirectional;
|
||||
import net.minecraft.block.BlockDispenser;
|
||||
import net.minecraft.block.BlockStairs;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
@@ -178,6 +175,16 @@ public class Mirror {
|
||||
}
|
||||
}
|
||||
|
||||
//Slabs
|
||||
if (blockState.getBlock() instanceof BlockSlab) {
|
||||
if (((BlockSlab) blockState.getBlock()).isDouble()) return blockState;
|
||||
if (blockState.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM) {
|
||||
return blockState.withProperty(BlockSlab.HALF, BlockSlab.EnumBlockHalf.TOP);
|
||||
} else {
|
||||
return blockState.withProperty(BlockSlab.HALF, BlockSlab.EnumBlockHalf.BOTTOM);
|
||||
}
|
||||
}
|
||||
|
||||
//Buttons, endrod, observer, piston
|
||||
if (blockState.getBlock() instanceof BlockDirectional) {
|
||||
if (blockState.getValue(BlockDirectional.FACING) == EnumFacing.DOWN) {
|
||||
|
||||
@@ -60,7 +60,7 @@ public class QuickReplace {
|
||||
//Mirror and Array synergy
|
||||
BlockSnapshot blockSnapshot = new BlockSnapshot(player.world, placedAgainstBlockPos, blockState);
|
||||
BlockEvent.PlaceEvent placeEvent = new BlockEvent.PlaceEvent(blockSnapshot, blockState, player, EnumHand.MAIN_HAND);
|
||||
Array.onBlockPlaced(placeEvent);
|
||||
Mirror.onBlockPlaced(placeEvent);
|
||||
Array.onBlockPlaced(placeEvent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.network.IGuiHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
|
||||
@@ -23,6 +25,7 @@ public class RandomizerBagGuiHandler implements IGuiHandler {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
if (ID == EffortlessBuilding.RANDOMIZER_BAG_GUI) {
|
||||
// Use the player's held item to create the client-side gui container
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package nl.requios.effortlessbuilding.item;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -10,11 +13,16 @@ import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.common.util.BlockSnapshot;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import nl.requios.effortlessbuilding.Array;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
import nl.requios.effortlessbuilding.Mirror;
|
||||
import nl.requios.effortlessbuilding.capability.ItemHandlerCapabilityProvider;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -32,7 +40,7 @@ public class ItemRandomizerBag extends Item {
|
||||
this.setUnlocalizedName(this.getRegistryName().toString());
|
||||
|
||||
this.maxStackSize = 1;
|
||||
//this.setCreativeTab(CreativeTabs.DECORATIONS); //TODO add back in
|
||||
this.setCreativeTab(CreativeTabs.DECORATIONS);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,6 +51,7 @@ public class ItemRandomizerBag extends Item {
|
||||
//Open inventory
|
||||
player.openGui(EffortlessBuilding.instance, EffortlessBuilding.RANDOMIZER_BAG_GUI, world, 0, 0, 0);
|
||||
} else {
|
||||
if (world.isRemote) return EnumActionResult.SUCCESS;
|
||||
//Use item
|
||||
//Get bag inventory
|
||||
ItemStack bag = player.getHeldItem(hand);
|
||||
@@ -57,8 +66,23 @@ public class ItemRandomizerBag extends Item {
|
||||
|
||||
if (toPlace.isEmpty()) return EnumActionResult.FAIL;
|
||||
|
||||
bag.setItemDamage(toPlace.getMetadata());
|
||||
return toPlace.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ);
|
||||
//Previously: use onItemUse to place block (no synergy)
|
||||
//bag.setItemDamage(toPlace.getMetadata());
|
||||
//toPlace.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ);
|
||||
|
||||
if (!world.getBlockState(pos).getBlock().isReplaceable(world, pos)) {
|
||||
pos = pos.offset(facing);
|
||||
}
|
||||
|
||||
IBlockState blockState = Block.getBlockFromItem(toPlace.getItem()).getStateForPlacement(world, pos, facing,
|
||||
hitX, hitY, hitZ, toPlace.getMetadata(), player, hand);
|
||||
world.setBlockState(pos, blockState);
|
||||
|
||||
//Synergy
|
||||
BlockSnapshot blockSnapshot = new BlockSnapshot(player.world, pos, blockState);
|
||||
BlockEvent.PlaceEvent placeEvent = new BlockEvent.PlaceEvent(blockSnapshot, blockState, player, hand);
|
||||
Mirror.onBlockPlaced(placeEvent);
|
||||
Array.onBlockPlaced(placeEvent);
|
||||
}
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
@@ -92,6 +116,7 @@ public class ItemRandomizerBag extends Item {
|
||||
|
||||
/**
|
||||
* Get the inventory of a randomizer bag by checking the capability.
|
||||
*
|
||||
* @param bag
|
||||
* @return
|
||||
*/
|
||||
@@ -102,6 +127,7 @@ public class ItemRandomizerBag extends Item {
|
||||
|
||||
/**
|
||||
* Pick a random slot from the bag. Empty slots will never get chosen.
|
||||
*
|
||||
* @param bagInventory
|
||||
* @return
|
||||
*/
|
||||
@@ -143,7 +169,7 @@ public class ItemRandomizerBag extends Item {
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, @Nullable World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
tooltip.add("Sneak + rightclick to open inventory");
|
||||
tooltip.add("Rightclick to place a random block");
|
||||
tooltip.add(TextFormatting.BLUE + "Rightclick" + TextFormatting.GRAY + " to place a random block");
|
||||
tooltip.add(TextFormatting.BLUE + "Sneak + rightclick" + TextFormatting.GRAY + " to open inventory");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.IThreadListener;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
@@ -25,7 +26,6 @@ import nl.requios.effortlessbuilding.BuildSettingsManager;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
import nl.requios.effortlessbuilding.gui.SettingsGui;
|
||||
import nl.requios.effortlessbuilding.network.BuildSettingsMessage;
|
||||
import nl.requios.effortlessbuilding.network.QuickReplaceMessage;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
@Mod.EventBusSubscriber(Side.CLIENT)
|
||||
@@ -60,12 +60,12 @@ public class ClientProxy implements IProxy {
|
||||
|
||||
@Override
|
||||
public EntityPlayer getPlayerEntityFromContext(MessageContext ctx) {
|
||||
return Minecraft.getMinecraft().player;//(ctx.side.isClient() ? Minecraft.getMinecraft().player : EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx));
|
||||
return (ctx.side.isClient() ? Minecraft.getMinecraft().player : ctx.getServerHandler().player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IThreadListener getThreadListenerFromContext(MessageContext ctx) {
|
||||
return Minecraft.getMinecraft();//(ctx.side.isClient() ? Minecraft.getMinecraft() : EffortlessBuilding.proxy.getThreadListenerFromContext(ctx));
|
||||
return (ctx.side.isClient() ? Minecraft.getMinecraft() : ((EntityPlayerMP) getPlayerEntityFromContext(ctx)).getServerWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,6 +16,7 @@ import nl.requios.effortlessbuilding.network.QuickReplaceMessage;
|
||||
|
||||
public class ServerProxy implements IProxy
|
||||
{
|
||||
//Only physical server! Singleplayer server is seen as clientproxy
|
||||
@Override
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"description": "Makes building easier by providing tools like mirrors, arrays, quickreplace and a block randomizer.",
|
||||
"version": "${version}",
|
||||
"mcversion": "${mcversion}",
|
||||
"url": "https://requios.nl/",
|
||||
"url": "https://minecraft.curseforge.com/projects/effortless-building",
|
||||
"updateUrl": "",
|
||||
"authorList": ["Requios"],
|
||||
"credits": "",
|
||||
|
||||
Reference in New Issue
Block a user