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