Compare commits
2 Commits
1.19-hotfi
...
1.16
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b91e6b9147 | ||
|
|
bb81595c3a |
@@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle'
|
|||||||
apply plugin: 'eclipse'
|
apply plugin: 'eclipse'
|
||||||
apply plugin: 'maven-publish'
|
apply plugin: 'maven-publish'
|
||||||
|
|
||||||
version = '1.16.3-2.24'
|
version = '1.16.3-2.32'
|
||||||
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'
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,10 @@
|
|||||||
package nl.requios.effortlessbuilding;
|
package nl.requios.effortlessbuilding;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.inventory.container.Container;
|
import net.minecraft.inventory.container.Container;
|
||||||
import net.minecraft.inventory.container.ContainerType;
|
import net.minecraft.inventory.container.ContainerType;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraft.util.registry.Registry;
|
|
||||||
import net.minecraft.util.text.StringTextComponent;
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.DistExecutor;
|
import net.minecraftforge.fml.DistExecutor;
|
||||||
@@ -18,22 +14,17 @@ import net.minecraftforge.fml.common.Mod;
|
|||||||
import net.minecraftforge.fml.config.ModConfig;
|
import net.minecraftforge.fml.config.ModConfig;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
|
|
||||||
import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
|
|
||||||
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
|
|
||||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||||
import net.minecraftforge.fml.network.IContainerFactory;
|
import net.minecraftforge.fml.network.IContainerFactory;
|
||||||
import net.minecraftforge.registries.DeferredRegister;
|
import net.minecraftforge.registries.DeferredRegister;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import nl.requios.effortlessbuilding.capability.ModeCapabilityManager;
|
import nl.requios.effortlessbuilding.capability.ModeCapabilityManager;
|
||||||
import nl.requios.effortlessbuilding.capability.ModifierCapabilityManager;
|
import nl.requios.effortlessbuilding.capability.ModifierCapabilityManager;
|
||||||
import nl.requios.effortlessbuilding.command.CommandReach;
|
|
||||||
import nl.requios.effortlessbuilding.compatibility.CompatHelper;
|
import nl.requios.effortlessbuilding.compatibility.CompatHelper;
|
||||||
|
import nl.requios.effortlessbuilding.gui.DiamondRandomizerBagContainer;
|
||||||
|
import nl.requios.effortlessbuilding.gui.GoldenRandomizerBagContainer;
|
||||||
import nl.requios.effortlessbuilding.gui.RandomizerBagContainer;
|
import nl.requios.effortlessbuilding.gui.RandomizerBagContainer;
|
||||||
import nl.requios.effortlessbuilding.item.ItemRandomizerBag;
|
import nl.requios.effortlessbuilding.item.*;
|
||||||
import nl.requios.effortlessbuilding.item.ItemReachUpgrade1;
|
|
||||||
import nl.requios.effortlessbuilding.item.ItemReachUpgrade2;
|
|
||||||
import nl.requios.effortlessbuilding.item.ItemReachUpgrade3;
|
|
||||||
import nl.requios.effortlessbuilding.network.PacketHandler;
|
import nl.requios.effortlessbuilding.network.PacketHandler;
|
||||||
import nl.requios.effortlessbuilding.proxy.ClientProxy;
|
import nl.requios.effortlessbuilding.proxy.ClientProxy;
|
||||||
import nl.requios.effortlessbuilding.proxy.IProxy;
|
import nl.requios.effortlessbuilding.proxy.IProxy;
|
||||||
@@ -47,43 +38,36 @@ import org.apache.logging.log4j.Logger;
|
|||||||
public class EffortlessBuilding {
|
public class EffortlessBuilding {
|
||||||
public static final String MODID = "effortlessbuilding";
|
public static final String MODID = "effortlessbuilding";
|
||||||
public static final Logger logger = LogManager.getLogger();
|
public static final Logger logger = LogManager.getLogger();
|
||||||
public static final ItemRandomizerBag ITEM_RANDOMIZER_BAG = new ItemRandomizerBag();
|
|
||||||
public static final ItemReachUpgrade1 ITEM_REACH_UPGRADE_1 = new ItemReachUpgrade1();
|
|
||||||
public static final ItemReachUpgrade2 ITEM_REACH_UPGRADE_2 = new ItemReachUpgrade2();
|
|
||||||
public static final ItemReachUpgrade3 ITEM_REACH_UPGRADE_3 = new ItemReachUpgrade3();
|
|
||||||
public static final Block[] BLOCKS = {
|
|
||||||
};
|
|
||||||
public static final Item[] ITEMS = {
|
|
||||||
ITEM_RANDOMIZER_BAG,
|
|
||||||
ITEM_REACH_UPGRADE_1,
|
|
||||||
ITEM_REACH_UPGRADE_2,
|
|
||||||
ITEM_REACH_UPGRADE_3
|
|
||||||
};
|
|
||||||
public static final DeferredRegister<ContainerType<?>> CONTAINERS = DeferredRegister.create(ForgeRegistries.CONTAINERS, EffortlessBuilding.MODID);
|
|
||||||
public static final RegistryObject<ContainerType<RandomizerBagContainer>> RANDOMIZER_BAG_CONTAINER = CONTAINERS.register("randomizer_bag", () -> registerContainer(RandomizerBagContainer::new));
|
|
||||||
public static final ResourceLocation RANDOMIZER_BAG_GUI = new ResourceLocation(EffortlessBuilding.MODID, "randomizer_bag");
|
|
||||||
public static EffortlessBuilding instance;
|
public static EffortlessBuilding instance;
|
||||||
public static IProxy proxy = DistExecutor.runForDist(() -> ClientProxy::new, () -> ServerProxy::new);
|
public static IProxy proxy = DistExecutor.runForDist(() -> ClientProxy::new, () -> ServerProxy::new);
|
||||||
|
|
||||||
|
//Registration
|
||||||
|
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||||
|
private static final DeferredRegister<ContainerType<?>> CONTAINERS = DeferredRegister.create(ForgeRegistries.CONTAINERS, EffortlessBuilding.MODID);
|
||||||
|
|
||||||
|
public static final RegistryObject<Item> RANDOMIZER_BAG_ITEM = ITEMS.register("randomizer_bag", RandomizerBagItem::new);
|
||||||
|
public static final RegistryObject<Item> GOLDEN_RANDOMIZER_BAG_ITEM = ITEMS.register("golden_randomizer_bag", GoldenRandomizerBagItem::new);
|
||||||
|
public static final RegistryObject<Item> DIAMOND_RANDOMIZER_BAG_ITEM = ITEMS.register("diamond_randomizer_bag", DiamondRandomizerBagItem::new);
|
||||||
|
public static final RegistryObject<Item> REACH_UPGRADE_1_ITEM = ITEMS.register("reach_upgrade1", ReachUpgrade1Item::new);
|
||||||
|
public static final RegistryObject<Item> REACH_UPGRADE_2_ITEM = ITEMS.register("reach_upgrade2", ReachUpgrade2Item::new);
|
||||||
|
public static final RegistryObject<Item> REACH_UPGRADE_3_ITEM = ITEMS.register("reach_upgrade3", ReachUpgrade3Item::new);
|
||||||
|
|
||||||
|
public static final RegistryObject<ContainerType<RandomizerBagContainer>> RANDOMIZER_BAG_CONTAINER = CONTAINERS.register("randomizer_bag", () -> registerContainer(RandomizerBagContainer::new));
|
||||||
|
public static final RegistryObject<ContainerType<GoldenRandomizerBagContainer>> GOLDEN_RANDOMIZER_BAG_CONTAINER = CONTAINERS.register("golden_randomizer_bag", () -> registerContainer(GoldenRandomizerBagContainer::new));
|
||||||
|
public static final RegistryObject<ContainerType<DiamondRandomizerBagContainer>> DIAMOND_RANDOMIZER_BAG_CONTAINER = CONTAINERS.register("diamond_randomizer_bag", () -> registerContainer(DiamondRandomizerBagContainer::new));
|
||||||
|
|
||||||
public EffortlessBuilding() {
|
public EffortlessBuilding() {
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
// Register the setup method for modloading
|
// Register ourselves for server and other game events we are interested in
|
||||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
|
FMLJavaModLoadingContext.get().getModEventBus().register(this);
|
||||||
// Register the enqueueIMC method for modloading
|
|
||||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueueIMC);
|
ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus());
|
||||||
// Register the processIMC method for modloading
|
CONTAINERS.register(FMLJavaModLoadingContext.get().getModEventBus());
|
||||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::processIMC);
|
|
||||||
// Register the clientSetup method for modloading
|
|
||||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientSetup);
|
|
||||||
|
|
||||||
//Register config
|
//Register config
|
||||||
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, BuildConfig.spec);
|
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, BuildConfig.spec);
|
||||||
|
|
||||||
// Register ourselves for server and other game events we are interested in
|
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
|
||||||
|
|
||||||
CONTAINERS.register(FMLJavaModLoadingContext.get().getModEventBus());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T extends Container> ContainerType<T> registerContainer(IContainerFactory<T> fact){
|
public static <T extends Container> ContainerType<T> registerContainer(IContainerFactory<T> fact){
|
||||||
@@ -128,25 +112,4 @@ public class EffortlessBuilding {
|
|||||||
|
|
||||||
proxy.clientSetup(event);
|
proxy.clientSetup(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void enqueueIMC(final InterModEnqueueEvent event) {
|
|
||||||
|
|
||||||
// some example code to dispatch IMC to another mod
|
|
||||||
// InterModComms.sendTo("examplemod", "helloworld", () -> { logger.info("Hello world from the MDK"); return "Hello world";});
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void processIMC(final InterModProcessEvent event) {
|
|
||||||
|
|
||||||
// some example code to receive and process InterModComms from other mods
|
|
||||||
// logger.info("Got IMC {}", event.getIMCStream().
|
|
||||||
// map(m->m.getMessageSupplier().get()).
|
|
||||||
// collect(Collectors.toList()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onServerStarting(FMLServerStartingEvent event) {
|
|
||||||
CommandReach.register(event.getServer().getCommands().getDispatcher());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,23 +43,7 @@ public class EventHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO 1.13 config
|
|
||||||
// @SubscribeEvent
|
|
||||||
// public static void onConfigChangedEvent(ConfigChangedEvent.OnConfigChangedEvent event)
|
|
||||||
// {
|
|
||||||
// if (event.getModID().equals(EffortlessBuilding.MODID))
|
|
||||||
// {
|
|
||||||
// ConfigManager.sync(EffortlessBuilding.MODID, Config.Type.INSTANCE);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @SubscribeEvent
|
|
||||||
// public static void onServerTick(TickEvent.ServerTickEvent event) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
//Only called serverside (except with lilypads...)
|
|
||||||
public static void onBlockPlaced(BlockEvent.EntityPlaceEvent event) {
|
public static void onBlockPlaced(BlockEvent.EntityPlaceEvent event) {
|
||||||
if (event.getWorld().isClientSide()) return;
|
if (event.getWorld().isClientSide()) return;
|
||||||
|
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
package nl.requios.effortlessbuilding;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.item.BlockItem;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraftforge.event.RegistryEvent;
|
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
|
||||||
|
|
||||||
// You can use EventBusSubscriber to automatically subscribe events on the contained class (this is subscribing to the MOD
|
|
||||||
// Event bus for receiving Registry Events)
|
|
||||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
|
||||||
public class ModEventHandler {
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void registerBlocks(RegistryEvent.Register<Block> event) {
|
|
||||||
event.getRegistry().registerAll(EffortlessBuilding.BLOCKS);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void registerItems(RegistryEvent.Register<Item> event) {
|
|
||||||
event.getRegistry().registerAll(EffortlessBuilding.ITEMS);
|
|
||||||
|
|
||||||
for (Block block : EffortlessBuilding.BLOCKS) {
|
|
||||||
event.getRegistry().register(new BlockItem(block, new Item.Properties()).setRegistryName(block.getRegistryName()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// @SubscribeEvent
|
|
||||||
// public static void registerContainerTypes(RegistryEvent.Register<ContainerType<?>> event) {
|
|
||||||
// event.getRegistry().register()
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -6,6 +6,7 @@ import net.minecraft.util.math.BlockPos;
|
|||||||
import net.minecraft.util.math.RayTraceContext;
|
import net.minecraft.util.math.RayTraceContext;
|
||||||
import net.minecraft.util.math.RayTraceResult;
|
import net.minecraft.util.math.RayTraceResult;
|
||||||
import net.minecraft.util.math.vector.Vector3d;
|
import net.minecraft.util.math.vector.Vector3d;
|
||||||
|
import net.minecraft.util.math.vector.Vector4f;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
import nl.requios.effortlessbuilding.buildmode.buildmodes.*;
|
import nl.requios.effortlessbuilding.buildmode.buildmodes.*;
|
||||||
import nl.requios.effortlessbuilding.buildmodifier.BuildModifiers;
|
import nl.requios.effortlessbuilding.buildmodifier.BuildModifiers;
|
||||||
@@ -245,27 +246,50 @@ public class BuildModes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public enum BuildModeEnum {
|
public enum BuildModeEnum {
|
||||||
NORMAL("effortlessbuilding.mode.normal", new Normal()),
|
NORMAL("normal", new Normal(), BuildModeCategoryEnum.BASIC),
|
||||||
NORMAL_PLUS("effortlessbuilding.mode.normal_plus", new NormalPlus(), OptionEnum.BUILD_SPEED),
|
NORMAL_PLUS("normal_plus", new NormalPlus(), BuildModeCategoryEnum.BASIC, OptionEnum.BUILD_SPEED),
|
||||||
LINE("effortlessbuilding.mode.line", new Line() /*, OptionEnum.THICKNESS*/),
|
LINE("line", new Line(), BuildModeCategoryEnum.BASIC /*, OptionEnum.THICKNESS*/),
|
||||||
WALL("effortlessbuilding.mode.wall", new Wall(), OptionEnum.FILL),
|
WALL("wall", new Wall(), BuildModeCategoryEnum.BASIC, OptionEnum.FILL),
|
||||||
FLOOR("effortlessbuilding.mode.floor", new Floor(), OptionEnum.FILL),
|
FLOOR("floor", new Floor(), BuildModeCategoryEnum.BASIC, OptionEnum.FILL),
|
||||||
DIAGONAL_LINE("effortlessbuilding.mode.diagonal_line", new DiagonalLine() /*, OptionEnum.THICKNESS*/),
|
CUBE("cube", new Cube(), BuildModeCategoryEnum.BASIC, OptionEnum.CUBE_FILL),
|
||||||
DIAGONAL_WALL("effortlessbuilding.mode.diagonal_wall", new DiagonalWall() /*, OptionEnum.FILL*/),
|
DIAGONAL_LINE("diagonal_line", new DiagonalLine(), BuildModeCategoryEnum.DIAGONAL /*, OptionEnum.THICKNESS*/),
|
||||||
SLOPE_FLOOR("effortlessbuilding.mode.slope_floor", new SlopeFloor(), OptionEnum.RAISED_EDGE),
|
DIAGONAL_WALL("diagonal_wall", new DiagonalWall(), BuildModeCategoryEnum.DIAGONAL /*, OptionEnum.FILL*/),
|
||||||
CIRCLE("effortlessbuilding.mode.circle", new Circle(), OptionEnum.CIRCLE_START, OptionEnum.FILL),
|
SLOPE_FLOOR("slope_floor", new SlopeFloor(), BuildModeCategoryEnum.DIAGONAL, OptionEnum.RAISED_EDGE),
|
||||||
CYLINDER("effortlessbuilding.mode.cylinder", new Cylinder(), OptionEnum.CIRCLE_START, OptionEnum.FILL),
|
CIRCLE("circle", new Circle(), BuildModeCategoryEnum.CIRCULAR, OptionEnum.CIRCLE_START, OptionEnum.FILL),
|
||||||
SPHERE("effortlessbuilding.mode.sphere", new Sphere(), OptionEnum.CIRCLE_START, OptionEnum.FILL),
|
CYLINDER("cylinder", new Cylinder(), BuildModeCategoryEnum.CIRCULAR, OptionEnum.CIRCLE_START, OptionEnum.FILL),
|
||||||
CUBE("effortlessbuilding.mode.cube", new Cube(), OptionEnum.CUBE_FILL);
|
SPHERE("sphere", new Sphere(), BuildModeCategoryEnum.CIRCULAR, OptionEnum.CIRCLE_START, OptionEnum.FILL);
|
||||||
|
|
||||||
public String name;
|
public String name;
|
||||||
public IBuildMode instance;
|
public IBuildMode instance;
|
||||||
|
public final BuildModeCategoryEnum category;
|
||||||
public OptionEnum[] options;
|
public OptionEnum[] options;
|
||||||
|
|
||||||
BuildModeEnum(String name, IBuildMode instance, OptionEnum... options) {
|
BuildModeEnum(String name, IBuildMode instance, BuildModeCategoryEnum category, OptionEnum... options) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.instance = instance;
|
this.instance = instance;
|
||||||
|
this.category = category;
|
||||||
this.options = options;
|
this.options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getNameKey() {
|
||||||
|
return "effortlessbuilding.mode." + name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescriptionKey() {
|
||||||
|
return "effortlessbuilding.modedescription." + name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum BuildModeCategoryEnum {
|
||||||
|
BASIC(new Vector4f(0f, .5f, 1f, .8f)),
|
||||||
|
DIAGONAL(new Vector4f(0.56f, 0.28f, 0.87f, .8f)),
|
||||||
|
CIRCULAR(new Vector4f(0.29f, 0.76f, 0.3f, 1f)),
|
||||||
|
ROOF(new Vector4f(0.83f, 0.87f, 0.23f, .8f));
|
||||||
|
|
||||||
|
public final Vector4f color;
|
||||||
|
|
||||||
|
BuildModeCategoryEnum(Vector4f color) {
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import net.minecraft.util.math.BlockPos;
|
|||||||
import net.minecraft.util.math.vector.Vector3d;
|
import net.minecraft.util.math.vector.Vector3d;
|
||||||
import net.minecraft.util.math.vector.Vector3i;
|
import net.minecraft.util.math.vector.Vector3i;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import nl.requios.effortlessbuilding.item.ItemRandomizerBag;
|
import nl.requios.effortlessbuilding.item.AbstractRandomizerBagItem;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -45,17 +45,19 @@ public class Array {
|
|||||||
Vector3i offset = new Vector3i(a.offset.getX(), a.offset.getY(), a.offset.getZ());
|
Vector3i offset = new Vector3i(a.offset.getX(), a.offset.getY(), a.offset.getZ());
|
||||||
|
|
||||||
//Randomizer bag synergy
|
//Randomizer bag synergy
|
||||||
|
AbstractRandomizerBagItem randomizerBagItem = null;
|
||||||
IItemHandler bagInventory = null;
|
IItemHandler bagInventory = null;
|
||||||
if (!itemStack.isEmpty() && itemStack.getItem() instanceof ItemRandomizerBag) {
|
if (!itemStack.isEmpty() && itemStack.getItem() instanceof AbstractRandomizerBagItem) {
|
||||||
bagInventory = ItemRandomizerBag.getBagInventory(itemStack);
|
randomizerBagItem = (AbstractRandomizerBagItem) itemStack.getItem();
|
||||||
|
bagInventory = randomizerBagItem.getBagInventory(itemStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < a.count; i++) {
|
for (int i = 0; i < a.count; i++) {
|
||||||
pos = pos.offset(offset);
|
pos = pos.offset(offset);
|
||||||
|
|
||||||
//Randomizer bag synergy
|
//Randomizer bag synergy
|
||||||
if (bagInventory != null) {
|
if (randomizerBagItem != null) {
|
||||||
itemStack = ItemRandomizerBag.pickRandomStack(bagInventory);
|
itemStack = randomizerBagItem.pickRandomStack(bagInventory);
|
||||||
blockState = BuildModifiers
|
blockState = BuildModifiers
|
||||||
.getBlockStateFromItem(itemStack, player, startPos, Direction.UP, new Vector3d(0, 0, 0), Hand.MAIN_HAND);
|
.getBlockStateFromItem(itemStack, player, startPos, Direction.UP, new Vector3d(0, 0, 0), Hand.MAIN_HAND);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,11 +17,10 @@ import net.minecraft.world.World;
|
|||||||
import nl.requios.effortlessbuilding.compatibility.CompatHelper;
|
import nl.requios.effortlessbuilding.compatibility.CompatHelper;
|
||||||
import nl.requios.effortlessbuilding.helper.InventoryHelper;
|
import nl.requios.effortlessbuilding.helper.InventoryHelper;
|
||||||
import nl.requios.effortlessbuilding.helper.SurvivalHelper;
|
import nl.requios.effortlessbuilding.helper.SurvivalHelper;
|
||||||
import nl.requios.effortlessbuilding.item.ItemRandomizerBag;
|
import nl.requios.effortlessbuilding.item.AbstractRandomizerBagItem;
|
||||||
import nl.requios.effortlessbuilding.render.BlockPreviewRenderer;
|
import nl.requios.effortlessbuilding.render.BlockPreviewRenderer;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -30,7 +29,7 @@ public class BuildModifiers {
|
|||||||
//Called from BuildModes
|
//Called from BuildModes
|
||||||
public static void onBlockPlaced(PlayerEntity player, List<BlockPos> startCoordinates, Direction sideHit, Vector3d hitVec, boolean placeStartPos) {
|
public static void onBlockPlaced(PlayerEntity player, List<BlockPos> startCoordinates, Direction sideHit, Vector3d hitVec, boolean placeStartPos) {
|
||||||
World world = player.level;
|
World world = player.level;
|
||||||
ItemRandomizerBag.renewRandomness();
|
AbstractRandomizerBagItem.renewRandomness();
|
||||||
|
|
||||||
//Format hitvec to 0.x
|
//Format hitvec to 0.x
|
||||||
hitVec = new Vector3d(Math.abs(hitVec.x - ((int) hitVec.x)), Math.abs(hitVec.y - ((int) hitVec.y)), Math.abs(hitVec.z - ((int) hitVec.z)));
|
hitVec = new Vector3d(Math.abs(hitVec.x - ((int) hitVec.x)), Math.abs(hitVec.y - ((int) hitVec.y)), Math.abs(hitVec.z - ((int) hitVec.z)));
|
||||||
@@ -193,7 +192,7 @@ public class BuildModifiers {
|
|||||||
ItemStack itemBlock = ItemStack.EMPTY;
|
ItemStack itemBlock = ItemStack.EMPTY;
|
||||||
if (itemStack.getItem() instanceof BlockItem) itemBlock = itemStack;
|
if (itemStack.getItem() instanceof BlockItem) itemBlock = itemStack;
|
||||||
else itemBlock = CompatHelper.getItemBlockFromStack(itemStack);
|
else itemBlock = CompatHelper.getItemBlockFromStack(itemStack);
|
||||||
ItemRandomizerBag.resetRandomness();
|
AbstractRandomizerBagItem.resetRandomness();
|
||||||
|
|
||||||
//Add blocks in posList first
|
//Add blocks in posList first
|
||||||
for (BlockPos blockPos : posList) {
|
for (BlockPos blockPos : posList) {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import net.minecraft.util.Hand;
|
|||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.vector.Vector3d;
|
import net.minecraft.util.math.vector.Vector3d;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import nl.requios.effortlessbuilding.item.ItemRandomizerBag;
|
import nl.requios.effortlessbuilding.item.AbstractRandomizerBagItem;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -65,9 +65,11 @@ public class Mirror {
|
|||||||
if (!isEnabled(m, startPos)) return blockStates;
|
if (!isEnabled(m, startPos)) return blockStates;
|
||||||
|
|
||||||
//Randomizer bag synergy
|
//Randomizer bag synergy
|
||||||
|
AbstractRandomizerBagItem randomizerBagItem = null;
|
||||||
IItemHandler bagInventory = null;
|
IItemHandler bagInventory = null;
|
||||||
if (!itemStack.isEmpty() && itemStack.getItem() instanceof ItemRandomizerBag) {
|
if (!itemStack.isEmpty() && itemStack.getItem() instanceof AbstractRandomizerBagItem) {
|
||||||
bagInventory = ItemRandomizerBag.getBagInventory(itemStack);
|
randomizerBagItem = (AbstractRandomizerBagItem) itemStack.getItem();
|
||||||
|
bagInventory = randomizerBagItem.getBagInventory(itemStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m.mirrorX)
|
if (m.mirrorX)
|
||||||
@@ -88,7 +90,7 @@ public class Mirror {
|
|||||||
|
|
||||||
//Randomizer bag synergy
|
//Randomizer bag synergy
|
||||||
if (bagInventory != null) {
|
if (bagInventory != null) {
|
||||||
itemStack = ItemRandomizerBag.pickRandomStack(bagInventory);
|
itemStack = ((AbstractRandomizerBagItem)itemStack.getItem()).pickRandomStack(bagInventory);
|
||||||
oldBlockState = BuildModifiers.getBlockStateFromItem(itemStack, player, oldBlockPos, Direction.UP, new Vector3d(0, 0, 0), hand);
|
oldBlockState = BuildModifiers.getBlockStateFromItem(itemStack, player, oldBlockPos, Direction.UP, new Vector3d(0, 0, 0), hand);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +115,7 @@ public class Mirror {
|
|||||||
|
|
||||||
//Randomizer bag synergy
|
//Randomizer bag synergy
|
||||||
if (bagInventory != null) {
|
if (bagInventory != null) {
|
||||||
itemStack = ItemRandomizerBag.pickRandomStack(bagInventory);
|
itemStack = ((AbstractRandomizerBagItem)itemStack.getItem()).pickRandomStack(bagInventory);
|
||||||
oldBlockState = BuildModifiers.getBlockStateFromItem(itemStack, player, oldBlockPos, Direction.UP, new Vector3d(0, 0, 0), hand);
|
oldBlockState = BuildModifiers.getBlockStateFromItem(itemStack, player, oldBlockPos, Direction.UP, new Vector3d(0, 0, 0), hand);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,7 +138,7 @@ public class Mirror {
|
|||||||
|
|
||||||
//Randomizer bag synergy
|
//Randomizer bag synergy
|
||||||
if (bagInventory != null) {
|
if (bagInventory != null) {
|
||||||
itemStack = ItemRandomizerBag.pickRandomStack(bagInventory);
|
itemStack = ((AbstractRandomizerBagItem)itemStack.getItem()).pickRandomStack(bagInventory);
|
||||||
oldBlockState = BuildModifiers.getBlockStateFromItem(itemStack, player, oldBlockPos, Direction.UP, new Vector3d(0, 0, 0), hand);
|
oldBlockState = BuildModifiers.getBlockStateFromItem(itemStack, player, oldBlockPos, Direction.UP, new Vector3d(0, 0, 0), hand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import net.minecraft.util.math.BlockPos;
|
|||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.vector.Vector3d;
|
import net.minecraft.util.math.vector.Vector3d;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import nl.requios.effortlessbuilding.item.ItemRandomizerBag;
|
import nl.requios.effortlessbuilding.item.AbstractRandomizerBagItem;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -74,9 +74,11 @@ public class RadialMirror {
|
|||||||
blockState = rotateOriginalBlockState(startAngleToCenter, blockState);
|
blockState = rotateOriginalBlockState(startAngleToCenter, blockState);
|
||||||
|
|
||||||
//Randomizer bag synergy
|
//Randomizer bag synergy
|
||||||
|
AbstractRandomizerBagItem randomizerBagItem = null;
|
||||||
IItemHandler bagInventory = null;
|
IItemHandler bagInventory = null;
|
||||||
if (!itemStack.isEmpty() && itemStack.getItem() instanceof ItemRandomizerBag) {
|
if (!itemStack.isEmpty() && itemStack.getItem() instanceof AbstractRandomizerBagItem) {
|
||||||
bagInventory = ItemRandomizerBag.getBagInventory(itemStack);
|
randomizerBagItem = (AbstractRandomizerBagItem) itemStack.getItem();
|
||||||
|
bagInventory = randomizerBagItem.getBagInventory(itemStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockState newBlockState;
|
BlockState newBlockState;
|
||||||
@@ -96,7 +98,7 @@ public class RadialMirror {
|
|||||||
|
|
||||||
//Randomizer bag synergy
|
//Randomizer bag synergy
|
||||||
if (bagInventory != null) {
|
if (bagInventory != null) {
|
||||||
itemStack = ItemRandomizerBag.pickRandomStack(bagInventory);
|
itemStack = randomizerBagItem.pickRandomStack(bagInventory);
|
||||||
newBlockState = BuildModifiers
|
newBlockState = BuildModifiers
|
||||||
.getBlockStateFromItem(itemStack, player, startPos, Direction.UP, new Vector3d(0, 0, 0), Hand.MAIN_HAND);
|
.getBlockStateFromItem(itemStack, player, startPos, Direction.UP, new Vector3d(0, 0, 0), Hand.MAIN_HAND);
|
||||||
|
|
||||||
|
|||||||
@@ -8,13 +8,17 @@ import net.minecraftforge.common.util.LazyOptional;
|
|||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import net.minecraftforge.items.ItemStackHandler;
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
import nl.requios.effortlessbuilding.item.ItemRandomizerBag;
|
import nl.requios.effortlessbuilding.item.RandomizerBagItem;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class ItemHandlerCapabilityProvider implements ICapabilitySerializable<CompoundNBT> {
|
public class ItemHandlerCapabilityProvider implements ICapabilitySerializable<CompoundNBT> {
|
||||||
IItemHandler itemHandler = new ItemStackHandler(ItemRandomizerBag.INV_SIZE);
|
IItemHandler itemHandler;
|
||||||
|
|
||||||
|
public ItemHandlerCapabilityProvider(int size) {
|
||||||
|
itemHandler = new ItemStackHandler(size);
|
||||||
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,37 +1,16 @@
|
|||||||
package nl.requios.effortlessbuilding.compatibility;
|
package nl.requios.effortlessbuilding.compatibility;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.item.BlockItem;
|
import net.minecraft.item.BlockItem;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.item.AbstractRandomizerBagItem;
|
||||||
import nl.requios.effortlessbuilding.item.ItemRandomizerBag;
|
|
||||||
|
|
||||||
public class CompatHelper {
|
public class CompatHelper {
|
||||||
//TODO 1.13 compatibility
|
|
||||||
// // Get a handle to the dank null item instance. This will remain null if the mod doesn't load
|
|
||||||
// // and all checks will fail, so it works.
|
|
||||||
// @GameRegistry.ObjectHolder("danknull:dank_null")
|
|
||||||
// public static final Item dankNullItem = null;
|
|
||||||
//
|
|
||||||
// public static IChiselsAndBitsProxy chiselsAndBitsProxy;
|
|
||||||
//
|
|
||||||
public static void setup() {
|
public static void setup() {
|
||||||
//TODO 1.13 compatibility
|
|
||||||
// if (Loader.isModLoaded("chiselsandbits")) {
|
|
||||||
// // reflection to avoid hard dependency
|
|
||||||
// try {
|
|
||||||
// chiselsAndBitsProxy = Class.forName("nl.requios.effortlessbuilding.compatibility.ActiveChiselsAndBitsProxy").asSubclass(ActiveChiselsAndBitsProxy.class).newInstance();
|
|
||||||
// } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// chiselsAndBitsProxy = new DummyChiselsAndBitsProxy();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the item given is a proxy for blocks. For now, we check for the randomizer bag,
|
// Check if the item given is a proxy for blocks. For now, we check for the randomizer bag,
|
||||||
@@ -40,10 +19,7 @@ public class CompatHelper {
|
|||||||
Item item = stack.getItem();
|
Item item = stack.getItem();
|
||||||
if (item instanceof BlockItem)
|
if (item instanceof BlockItem)
|
||||||
return true;
|
return true;
|
||||||
return item instanceof ItemRandomizerBag;
|
return item instanceof AbstractRandomizerBagItem;
|
||||||
//TODO 1.13 compatibility
|
|
||||||
// if (item == dankNullItem)
|
|
||||||
// return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the block to be placed by this proxy. For the /dank/null, it's the slot stack
|
// Get the block to be placed by this proxy. For the /dank/null, it's the slot stack
|
||||||
@@ -55,24 +31,17 @@ public class CompatHelper {
|
|||||||
return proxy;
|
return proxy;
|
||||||
|
|
||||||
//Randomizer Bag
|
//Randomizer Bag
|
||||||
if (proxyItem instanceof ItemRandomizerBag) {
|
if (proxyItem instanceof AbstractRandomizerBagItem) {
|
||||||
ItemStack itemStack = proxy;
|
ItemStack itemStack = proxy;
|
||||||
while (!(itemStack.getItem() instanceof BlockItem || itemStack.isEmpty())) {
|
while (!(itemStack.getItem() instanceof BlockItem || itemStack.isEmpty())) {
|
||||||
if (itemStack.getItem() instanceof ItemRandomizerBag)
|
if (itemStack.getItem() instanceof AbstractRandomizerBagItem) {
|
||||||
itemStack = ItemRandomizerBag.pickRandomStack(ItemRandomizerBag.getBagInventory(itemStack));
|
AbstractRandomizerBagItem randomizerBagItem = (AbstractRandomizerBagItem) itemStack.getItem();
|
||||||
|
itemStack = randomizerBagItem.pickRandomStack(randomizerBagItem.getBagInventory(itemStack));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return itemStack;
|
return itemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO 1.13 compatibility
|
|
||||||
//Dank Null
|
|
||||||
// if (proxyItem == dankNullItem) {
|
|
||||||
// int index = 0;
|
|
||||||
// if (proxy.hasTagCompound() && proxy.getTagCompound().hasKey("selectedIndex"))
|
|
||||||
// index = proxy.getTagCompound().getInteger("selectedIndex");
|
|
||||||
// return proxy.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null).getStackInSlot(index);
|
|
||||||
// }
|
|
||||||
|
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,49 +51,12 @@ public class CompatHelper {
|
|||||||
Item blockItem = Item.byBlock(state.getBlock());
|
Item blockItem = Item.byBlock(state.getBlock());
|
||||||
if (stack.getItem() instanceof BlockItem)
|
if (stack.getItem() instanceof BlockItem)
|
||||||
return stack;
|
return stack;
|
||||||
else if (stack.getItem() instanceof ItemRandomizerBag) {
|
else if (stack.getItem() instanceof AbstractRandomizerBagItem) {
|
||||||
IItemHandler bagInventory = ItemRandomizerBag.getBagInventory(stack);
|
AbstractRandomizerBagItem randomizerBagItem = (AbstractRandomizerBagItem) stack.getItem();
|
||||||
return ItemRandomizerBag.findStack(bagInventory, blockItem);
|
IItemHandler bagInventory = randomizerBagItem.getBagInventory(stack);
|
||||||
|
return randomizerBagItem.findStack(bagInventory, blockItem);
|
||||||
}
|
}
|
||||||
//TODO 1.13 compatibility
|
|
||||||
// else if (stack.getItem() == dankNullItem) {
|
|
||||||
// int index = itemHandlerSlotForItem(stack, blockItem);
|
|
||||||
// if (index >= 0)
|
|
||||||
// return stack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null).getStackInSlot(index);
|
|
||||||
// }
|
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle IItemHandler slot stacks not being modifiable. We must call IItemHandler#extractItem,
|
|
||||||
// because the ItemStack returned by IItemHandler#getStackInSlot isn't modifiable.
|
|
||||||
public static void shrinkStack(ItemStack origStack, ItemStack curStack, PlayerEntity player) {
|
|
||||||
//TODO 1.13 compatibility, offhand support
|
|
||||||
//Hacky way to get the origstack, because given origStack is itemblock stack and never proxy
|
|
||||||
// origStack = player.getHeldItem(EnumHand.MAIN_HAND);
|
|
||||||
|
|
||||||
// if (origStack.getItem() == dankNullItem) {
|
|
||||||
// int index = itemHandlerSlotForItem(origStack, curStack.getItem());
|
|
||||||
// origStack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null).extractItem(index, 1, false);
|
|
||||||
// } else
|
|
||||||
curStack.shrink(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int itemHandlerSlotForItem(ItemStack stack, Item blockItem) {
|
|
||||||
LazyOptional<IItemHandler> itemHandlerLazyOptional = stack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
|
|
||||||
IItemHandler handler = itemHandlerLazyOptional.orElse(null);
|
|
||||||
|
|
||||||
if (handler == null) {
|
|
||||||
EffortlessBuilding.logger.warn("Itemblock proxy has no item handler capability!");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < handler.getSlots(); i++) {
|
|
||||||
ItemStack ref = handler.getStackInSlot(i);
|
|
||||||
if (ref.getItem() instanceof BlockItem)
|
|
||||||
if (ref.getItem() == blockItem)
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,149 @@
|
|||||||
|
package nl.requios.effortlessbuilding.gui;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
|
import net.minecraft.inventory.container.ClickType;
|
||||||
|
import net.minecraft.inventory.container.Container;
|
||||||
|
import net.minecraft.inventory.container.ContainerType;
|
||||||
|
import net.minecraft.inventory.container.Slot;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.network.PacketBuffer;
|
||||||
|
import net.minecraft.util.Hand;
|
||||||
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
|
import net.minecraftforge.items.SlotItemHandler;
|
||||||
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
|
import nl.requios.effortlessbuilding.item.DiamondRandomizerBagItem;
|
||||||
|
|
||||||
|
public class DiamondRandomizerBagContainer extends Container {
|
||||||
|
|
||||||
|
private static final int INV_START = DiamondRandomizerBagItem.INV_SIZE,
|
||||||
|
INV_END = INV_START + 26,
|
||||||
|
HOTBAR_START = INV_END + 1,
|
||||||
|
HOTBAR_END = HOTBAR_START + 8;
|
||||||
|
private final IItemHandler bagInventory;
|
||||||
|
|
||||||
|
public DiamondRandomizerBagContainer(ContainerType<?> type, int id){
|
||||||
|
super(type, id);
|
||||||
|
bagInventory = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Client
|
||||||
|
public DiamondRandomizerBagContainer(int id, PlayerInventory playerInventory, PacketBuffer packetBuffer) {
|
||||||
|
this(id, playerInventory);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Server?
|
||||||
|
public DiamondRandomizerBagContainer(int containerId, PlayerInventory playerInventory) {
|
||||||
|
this(containerId, playerInventory, new ItemStackHandler(DiamondRandomizerBagItem.INV_SIZE));
|
||||||
|
}
|
||||||
|
|
||||||
|
public DiamondRandomizerBagContainer(int containerId, PlayerInventory playerInventory, IItemHandler inventory) {
|
||||||
|
super(EffortlessBuilding.DIAMOND_RANDOMIZER_BAG_CONTAINER.get(), containerId);
|
||||||
|
bagInventory = inventory;
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; ++i) {
|
||||||
|
for (int j = 0; j < 9; ++j) {
|
||||||
|
this.addSlot(new SlotItemHandler(bagInventory, j + i * 9, 8 + j * 18, 18 + i * 18));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// add player inventory slots
|
||||||
|
for (int i = 0; i < 3; ++i) {
|
||||||
|
for (int j = 0; j < 9; ++j) {
|
||||||
|
addSlot(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// add hotbar slots
|
||||||
|
for (int i = 0; i < 9; ++i) {
|
||||||
|
addSlot(new Slot(playerInventory, i, 8 + i * 18, 142));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean stillValid(PlayerEntity playerIn) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Slot getSlot(int parSlotIndex) {
|
||||||
|
if (parSlotIndex >= slots.size())
|
||||||
|
parSlotIndex = slots.size() - 1;
|
||||||
|
return super.getSlot(parSlotIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack quickMoveStack(PlayerEntity playerIn, int slotIndex) {
|
||||||
|
ItemStack itemstack = ItemStack.EMPTY;
|
||||||
|
Slot slot = this.slots.get(slotIndex);
|
||||||
|
|
||||||
|
if (slot != null && slot.hasItem()) {
|
||||||
|
ItemStack itemstack1 = slot.getItem();
|
||||||
|
itemstack = itemstack1.copy();
|
||||||
|
|
||||||
|
// If item is in our custom inventory
|
||||||
|
if (slotIndex < INV_START) {
|
||||||
|
// try to place in player inventory / action bar
|
||||||
|
if (!this.moveItemStackTo(itemstack1, INV_START, HOTBAR_END + 1, true)) {
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
slot.onQuickCraft(itemstack1, itemstack);
|
||||||
|
}
|
||||||
|
// Item is in inventory / hotbar, try to place in custom inventory or armor slots
|
||||||
|
else {
|
||||||
|
/**
|
||||||
|
* Implementation number 1: Shift-click into your custom inventory
|
||||||
|
*/
|
||||||
|
if (slotIndex >= INV_START) {
|
||||||
|
// place in custom inventory
|
||||||
|
if (!this.moveItemStackTo(itemstack1, 0, INV_START, false)) {
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemstack1.getCount() == 0) {
|
||||||
|
slot.set(ItemStack.EMPTY);
|
||||||
|
} else {
|
||||||
|
slot.setChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemstack1.getCount() == itemstack.getCount()) {
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
slot.onTake(playerIn, itemstack1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return itemstack;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* You should override this method to prevent the player from moving the stack that
|
||||||
|
* opened the inventory, otherwise if the player moves it, the inventory will not
|
||||||
|
* be able to save properly
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ItemStack clicked(int slot, int dragType, ClickType clickTypeIn, PlayerEntity player) {
|
||||||
|
// this will prevent the player from interacting with the item that opened the inventory:
|
||||||
|
if (slot >= 0 && getSlot(slot) != null && getSlot(slot).getItem().equals(player.getItemInHand(Hand.MAIN_HAND))) {
|
||||||
|
//Do nothing;
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
}
|
||||||
|
return super.clicked(slot, dragType, clickTypeIn, player);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback for when the crafting gui is closed.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void removed(PlayerEntity player) {
|
||||||
|
super.removed(player);
|
||||||
|
if (!player.level.isClientSide) {
|
||||||
|
broadcastChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package nl.requios.effortlessbuilding.gui;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||||
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
|
|
||||||
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
|
public class DiamondRandomizerBagScreen extends ContainerScreen<DiamondRandomizerBagContainer> {
|
||||||
|
private static final ResourceLocation guiTextures =
|
||||||
|
new ResourceLocation(EffortlessBuilding.MODID, "textures/gui/container/diamondrandomizerbag.png");
|
||||||
|
|
||||||
|
public DiamondRandomizerBagScreen(DiamondRandomizerBagContainer randomizerBagContainer, PlayerInventory playerInventory, ITextComponent title) {
|
||||||
|
super(randomizerBagContainer, playerInventory, title);
|
||||||
|
imageHeight = 167;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(MatrixStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||||
|
renderBackground(ms);
|
||||||
|
super.render(ms, mouseX, mouseY, partialTicks);
|
||||||
|
this.renderTooltip(ms, mouseX, mouseY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void renderLabels(MatrixStack ms, int mouseX, int mouseY) {
|
||||||
|
font.draw(ms, this.title, 8, 6, 0x404040);
|
||||||
|
font.draw(ms, inventory.getDisplayName(), 8, imageHeight - 96 + 2, 0x404040);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void renderBg(MatrixStack ms, float partialTicks, int mouseX, int mouseY) {
|
||||||
|
RenderSystem.color3f(1.0F, 1.0F, 1.0F);
|
||||||
|
minecraft.getTextureManager().bind(guiTextures);
|
||||||
|
int marginHorizontal = (width - imageWidth) / 2;
|
||||||
|
int marginVertical = (height - imageHeight) / 2;
|
||||||
|
blit(ms, marginHorizontal, marginVertical, 0, 0, imageWidth, imageHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,147 @@
|
|||||||
|
package nl.requios.effortlessbuilding.gui;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
|
import net.minecraft.inventory.container.ClickType;
|
||||||
|
import net.minecraft.inventory.container.Container;
|
||||||
|
import net.minecraft.inventory.container.ContainerType;
|
||||||
|
import net.minecraft.inventory.container.Slot;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.network.PacketBuffer;
|
||||||
|
import net.minecraft.util.Hand;
|
||||||
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
|
import net.minecraftforge.items.SlotItemHandler;
|
||||||
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
|
import nl.requios.effortlessbuilding.item.GoldenRandomizerBagItem;
|
||||||
|
|
||||||
|
public class GoldenRandomizerBagContainer extends Container {
|
||||||
|
|
||||||
|
private static final int INV_START = GoldenRandomizerBagItem.INV_SIZE,
|
||||||
|
INV_END = INV_START + 26,
|
||||||
|
HOTBAR_START = INV_END + 1,
|
||||||
|
HOTBAR_END = HOTBAR_START + 8;
|
||||||
|
private final IItemHandler bagInventory;
|
||||||
|
|
||||||
|
public GoldenRandomizerBagContainer(ContainerType<?> type, int id){
|
||||||
|
super(type, id);
|
||||||
|
bagInventory = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Client
|
||||||
|
public GoldenRandomizerBagContainer(int id, PlayerInventory playerInventory, PacketBuffer packetBuffer) {
|
||||||
|
this(id, playerInventory);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Server?
|
||||||
|
public GoldenRandomizerBagContainer(int containerId, PlayerInventory playerInventory) {
|
||||||
|
this(containerId, playerInventory, new ItemStackHandler(GoldenRandomizerBagItem.INV_SIZE));
|
||||||
|
}
|
||||||
|
|
||||||
|
public GoldenRandomizerBagContainer(int containerId, PlayerInventory playerInventory, IItemHandler inventory) {
|
||||||
|
super(EffortlessBuilding.GOLDEN_RANDOMIZER_BAG_CONTAINER.get(), containerId);
|
||||||
|
bagInventory = inventory;
|
||||||
|
|
||||||
|
for (int i = 0; i < GoldenRandomizerBagItem.INV_SIZE; ++i) {
|
||||||
|
this.addSlot(new SlotItemHandler(bagInventory, i, 8 + (18 * i), 20));
|
||||||
|
}
|
||||||
|
|
||||||
|
// add player inventory slots
|
||||||
|
for (int i = 0; i < 3; ++i) {
|
||||||
|
for (int j = 0; j < 9; ++j) {
|
||||||
|
addSlot(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 51 + i * 18));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// add hotbar slots
|
||||||
|
for (int i = 0; i < 9; ++i) {
|
||||||
|
addSlot(new Slot(playerInventory, i, 8 + i * 18, 109));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean stillValid(PlayerEntity playerIn) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Slot getSlot(int parSlotIndex) {
|
||||||
|
if (parSlotIndex >= slots.size())
|
||||||
|
parSlotIndex = slots.size() - 1;
|
||||||
|
return super.getSlot(parSlotIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack quickMoveStack(PlayerEntity playerIn, int slotIndex) {
|
||||||
|
ItemStack itemstack = ItemStack.EMPTY;
|
||||||
|
Slot slot = this.slots.get(slotIndex);
|
||||||
|
|
||||||
|
if (slot != null && slot.hasItem()) {
|
||||||
|
ItemStack itemstack1 = slot.getItem();
|
||||||
|
itemstack = itemstack1.copy();
|
||||||
|
|
||||||
|
// If item is in our custom inventory
|
||||||
|
if (slotIndex < INV_START) {
|
||||||
|
// try to place in player inventory / action bar
|
||||||
|
if (!this.moveItemStackTo(itemstack1, INV_START, HOTBAR_END + 1, true)) {
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
slot.onQuickCraft(itemstack1, itemstack);
|
||||||
|
}
|
||||||
|
// Item is in inventory / hotbar, try to place in custom inventory or armor slots
|
||||||
|
else {
|
||||||
|
/**
|
||||||
|
* Implementation number 1: Shift-click into your custom inventory
|
||||||
|
*/
|
||||||
|
if (slotIndex >= INV_START) {
|
||||||
|
// place in custom inventory
|
||||||
|
if (!this.moveItemStackTo(itemstack1, 0, INV_START, false)) {
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemstack1.getCount() == 0) {
|
||||||
|
slot.set(ItemStack.EMPTY);
|
||||||
|
} else {
|
||||||
|
slot.setChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemstack1.getCount() == itemstack.getCount()) {
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
slot.onTake(playerIn, itemstack1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return itemstack;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* You should override this method to prevent the player from moving the stack that
|
||||||
|
* opened the inventory, otherwise if the player moves it, the inventory will not
|
||||||
|
* be able to save properly
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ItemStack clicked(int slot, int dragType, ClickType clickTypeIn, PlayerEntity player) {
|
||||||
|
// this will prevent the player from interacting with the item that opened the inventory:
|
||||||
|
if (slot >= 0 && getSlot(slot) != null && getSlot(slot).getItem().equals(player.getItemInHand(Hand.MAIN_HAND))) {
|
||||||
|
//Do nothing;
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
}
|
||||||
|
return super.clicked(slot, dragType, clickTypeIn, player);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback for when the crafting gui is closed.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void removed(PlayerEntity player) {
|
||||||
|
super.removed(player);
|
||||||
|
if (!player.level.isClientSide) {
|
||||||
|
broadcastChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package nl.requios.effortlessbuilding.gui;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||||
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
|
|
||||||
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
|
public class GoldenRandomizerBagScreen extends ContainerScreen<GoldenRandomizerBagContainer> {
|
||||||
|
private static final ResourceLocation guiTextures =
|
||||||
|
new ResourceLocation(EffortlessBuilding.MODID, "textures/gui/container/goldenrandomizerbag.png");
|
||||||
|
|
||||||
|
public GoldenRandomizerBagScreen(GoldenRandomizerBagContainer randomizerBagContainer, PlayerInventory playerInventory, ITextComponent title) {
|
||||||
|
super(randomizerBagContainer, playerInventory, title);
|
||||||
|
imageHeight = 134;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(MatrixStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||||
|
renderBackground(ms);
|
||||||
|
super.render(ms, mouseX, mouseY, partialTicks);
|
||||||
|
this.renderTooltip(ms, mouseX, mouseY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void renderLabels(MatrixStack ms, int mouseX, int mouseY) {
|
||||||
|
font.draw(ms, this.title, 8, 6, 0x404040);
|
||||||
|
font.draw(ms, inventory.getDisplayName(), 8, imageHeight - 96 + 2, 0x404040);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void renderBg(MatrixStack ms, float partialTicks, int mouseX, int mouseY) {
|
||||||
|
RenderSystem.color3f(1.0F, 1.0F, 1.0F);
|
||||||
|
minecraft.getTextureManager().bind(guiTextures);
|
||||||
|
int marginHorizontal = (width - imageWidth) / 2;
|
||||||
|
int marginVertical = (height - imageHeight) / 2;
|
||||||
|
blit(ms, marginHorizontal, marginVertical, 0, 0, imageWidth, imageHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,12 +13,14 @@ import net.minecraftforge.items.IItemHandler;
|
|||||||
import net.minecraftforge.items.ItemStackHandler;
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
import net.minecraftforge.items.SlotItemHandler;
|
import net.minecraftforge.items.SlotItemHandler;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
import nl.requios.effortlessbuilding.item.ItemRandomizerBag;
|
import nl.requios.effortlessbuilding.item.RandomizerBagItem;
|
||||||
|
|
||||||
public class RandomizerBagContainer extends Container {
|
public class RandomizerBagContainer extends Container {
|
||||||
|
|
||||||
private static final int INV_START = ItemRandomizerBag.INV_SIZE, INV_END = INV_START + 26,
|
private static final int INV_START = RandomizerBagItem.INV_SIZE,
|
||||||
HOTBAR_START = INV_END + 1, HOTBAR_END = HOTBAR_START + 8;
|
INV_END = INV_START + 26,
|
||||||
|
HOTBAR_START = INV_END + 1,
|
||||||
|
HOTBAR_END = HOTBAR_START + 8;
|
||||||
private final IItemHandler bagInventory;
|
private final IItemHandler bagInventory;
|
||||||
|
|
||||||
public RandomizerBagContainer(ContainerType<?> type, int id){
|
public RandomizerBagContainer(ContainerType<?> type, int id){
|
||||||
@@ -33,27 +35,26 @@ public class RandomizerBagContainer extends Container {
|
|||||||
|
|
||||||
//Server?
|
//Server?
|
||||||
public RandomizerBagContainer(int containerId, PlayerInventory playerInventory) {
|
public RandomizerBagContainer(int containerId, PlayerInventory playerInventory) {
|
||||||
this(containerId, playerInventory, new ItemStackHandler(ItemRandomizerBag.INV_SIZE));
|
this(containerId, playerInventory, new ItemStackHandler(RandomizerBagItem.INV_SIZE));
|
||||||
}
|
}
|
||||||
|
|
||||||
public RandomizerBagContainer(int containerId, PlayerInventory playerInventory, IItemHandler inventory) {
|
public RandomizerBagContainer(int containerId, PlayerInventory playerInventory, IItemHandler inventory) {
|
||||||
super(EffortlessBuilding.RANDOMIZER_BAG_CONTAINER.get(), containerId);
|
super(EffortlessBuilding.RANDOMIZER_BAG_CONTAINER.get(), containerId);
|
||||||
bagInventory = inventory;
|
bagInventory = inventory;
|
||||||
|
|
||||||
for (int i = 0; i < ItemRandomizerBag.INV_SIZE; ++i) {
|
for (int i = 0; i < RandomizerBagItem.INV_SIZE; ++i) {
|
||||||
this.addSlot(new SlotItemHandler(bagInventory, i, 44 + (18 * i), 20));
|
this.addSlot(new SlotItemHandler(bagInventory, i, 44 + (18 * i), 20));
|
||||||
}
|
}
|
||||||
|
|
||||||
// add player inventory slots
|
// add player inventory slots
|
||||||
int i;
|
for (int i = 0; i < 3; ++i) {
|
||||||
for (i = 0; i < 3; ++i) {
|
|
||||||
for (int j = 0; j < 9; ++j) {
|
for (int j = 0; j < 9; ++j) {
|
||||||
addSlot(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 51 + i * 18));
|
addSlot(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 51 + i * 18));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add hotbar slots
|
// add hotbar slots
|
||||||
for (i = 0; i < 9; ++i) {
|
for (int i = 0; i < 9; ++i) {
|
||||||
addSlot(new Slot(playerInventory, i, 8 + i * 18, 109));
|
addSlot(new Slot(playerInventory, i, 8 + i * 18, 109));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -99,7 +100,6 @@ public class RandomizerBagContainer extends Container {
|
|||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itemstack1.getCount() == 0) {
|
if (itemstack1.getCount() == 0) {
|
||||||
@@ -122,11 +122,13 @@ public class RandomizerBagContainer extends Container {
|
|||||||
* You should override this method to prevent the player from moving the stack that
|
* You should override this method to prevent the player from moving the stack that
|
||||||
* opened the inventory, otherwise if the player moves it, the inventory will not
|
* opened the inventory, otherwise if the player moves it, the inventory will not
|
||||||
* be able to save properly
|
* be able to save properly
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ItemStack clicked(int slot, int dragType, ClickType clickTypeIn, PlayerEntity player) {
|
public ItemStack clicked(int slot, int dragType, ClickType clickTypeIn, PlayerEntity player) {
|
||||||
// this will prevent the player from interacting with the item that opened the inventory:
|
// this will prevent the player from interacting with the item that opened the inventory:
|
||||||
if (slot >= 0 && getSlot(slot) != null && getSlot(slot).getItem().equals(player.getItemInHand(Hand.MAIN_HAND))) {
|
if (slot >= 0 && getSlot(slot) != null && getSlot(slot).getItem().equals(player.getItemInHand(Hand.MAIN_HAND))) {
|
||||||
|
//Do nothing;
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
return super.clicked(slot, dragType, clickTypeIn, player);
|
return super.clicked(slot, dragType, clickTypeIn, player);
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ public class RandomizerBagScreen extends ContainerScreen<RandomizerBagContainer>
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderLabels(MatrixStack ms, int mouseX, int mouseY) {
|
protected void renderLabels(MatrixStack ms, int mouseX, int mouseY) {
|
||||||
font.drawShadow(ms, this.title, 8, 6, 0x404040);
|
font.draw(ms, this.title, 8, 6, 0x404040);
|
||||||
font.drawShadow(ms, inventory.getDisplayName(), 8, imageHeight - 96 + 2, 0x404040);
|
font.draw(ms, inventory.getDisplayName(), 8, imageHeight - 96 + 2, 0x404040);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package nl.requios.effortlessbuilding.gui.buildmode;
|
package nl.requios.effortlessbuilding.gui.buildmode;
|
||||||
|
|
||||||
import com.google.common.base.Stopwatch;
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import mcp.MethodsReturnNonnullByDefault;
|
import mcp.MethodsReturnNonnullByDefault;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.audio.SimpleSound;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.renderer.BufferBuilder;
|
import net.minecraft.client.renderer.BufferBuilder;
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
@@ -13,21 +13,27 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
|||||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
import net.minecraft.client.settings.KeyBinding;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
|
import net.minecraft.util.SoundCategory;
|
||||||
|
import net.minecraft.util.SoundEvents;
|
||||||
|
import net.minecraft.util.math.vector.Vector4f;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
import net.minecraft.util.text.TextFormatting;
|
||||||
import net.minecraft.util.text.TranslationTextComponent;
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
import nl.requios.effortlessbuilding.ModClientEventHandler;
|
import nl.requios.effortlessbuilding.ModClientEventHandler;
|
||||||
|
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
||||||
import nl.requios.effortlessbuilding.buildmode.ModeSettingsManager;
|
import nl.requios.effortlessbuilding.buildmode.ModeSettingsManager;
|
||||||
|
import nl.requios.effortlessbuilding.network.ModeActionMessage;
|
||||||
|
import nl.requios.effortlessbuilding.network.ModeSettingsMessage;
|
||||||
|
import nl.requios.effortlessbuilding.network.PacketHandler;
|
||||||
import nl.requios.effortlessbuilding.proxy.ClientProxy;
|
import nl.requios.effortlessbuilding.proxy.ClientProxy;
|
||||||
import org.apache.commons.lang3.text.WordUtils;
|
import org.apache.commons.lang3.text.WordUtils;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import static nl.requios.effortlessbuilding.buildmode.BuildModes.BuildModeEnum;
|
|
||||||
import static nl.requios.effortlessbuilding.buildmode.ModeOptions.*;
|
import static nl.requios.effortlessbuilding.buildmode.ModeOptions.*;
|
||||||
|
|
||||||
import nl.requios.effortlessbuilding.buildmode.BuildModes.BuildModeEnum;
|
import nl.requios.effortlessbuilding.buildmode.BuildModes.BuildModeEnum;
|
||||||
@@ -35,8 +41,8 @@ import nl.requios.effortlessbuilding.buildmode.ModeOptions.ActionEnum;
|
|||||||
import nl.requios.effortlessbuilding.buildmode.ModeOptions.OptionEnum;
|
import nl.requios.effortlessbuilding.buildmode.ModeOptions.OptionEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* From Chisels and Bits by AlgorithmX2
|
* Initially from Chisels and Bits by AlgorithmX2
|
||||||
* https://github.com/AlgorithmX2/Chisels-and-Bits/blob/1.12/src/main/java/mod/chiselsandbits/client/gui/ChiselsAndBitsMenu.java
|
* <a href="https://github.com/AlgorithmX2/Chisels-and-Bits/blob/1.12/src/main/java/mod/chiselsandbits/client/gui/ChiselsAndBitsMenu.java">Link</a>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
@@ -44,55 +50,66 @@ import nl.requios.effortlessbuilding.buildmode.ModeOptions.OptionEnum;
|
|||||||
public class RadialMenu extends Screen {
|
public class RadialMenu extends Screen {
|
||||||
|
|
||||||
public static final RadialMenu instance = new RadialMenu();
|
public static final RadialMenu instance = new RadialMenu();
|
||||||
private final float TIME_SCALE = 0.01f;
|
|
||||||
|
private final Vector4f radialButtonColor = new Vector4f(0f, 0f, 0f, .5f);
|
||||||
|
private final Vector4f sideButtonColor = new Vector4f(.5f, .5f, .5f, .5f);
|
||||||
|
private final Vector4f highlightColor = new Vector4f(.6f, .8f, 1f, .6f);
|
||||||
|
private final Vector4f selectedColor = new Vector4f(0f, .5f, 1f, .5f);
|
||||||
|
private final Vector4f highlightSelectedColor = new Vector4f(0.2f, .7f, 1f, .7f);
|
||||||
|
|
||||||
|
private final int whiteTextColor = 0xffffffff;
|
||||||
|
private final int watermarkTextColor = 0x88888888;
|
||||||
|
private final int descriptionTextColor = 0xdd888888;
|
||||||
|
private final int optionTextColor = 0xeeeeeeff;
|
||||||
|
|
||||||
|
private final double ringInnerEdge = 30;
|
||||||
|
private final double ringOuterEdge = 65;
|
||||||
|
private final double categoryLineWidth = 1;
|
||||||
|
private final double textDistance = 75;
|
||||||
|
private final double buttonDistance = 105;
|
||||||
|
private final float fadeSpeed = 0.3f;
|
||||||
|
private final int descriptionHeight = 100;
|
||||||
|
|
||||||
public BuildModeEnum switchTo = null;
|
public BuildModeEnum switchTo = null;
|
||||||
public ActionEnum doAction = null;
|
public ActionEnum doAction = null;
|
||||||
public boolean actionUsed = false;
|
public boolean performedActionUsingMouse;
|
||||||
private float visibility = 0.0f;
|
|
||||||
private Stopwatch lastChange = Stopwatch.createStarted();
|
private float visibility;
|
||||||
|
|
||||||
public RadialMenu() {
|
public RadialMenu() {
|
||||||
super(new TranslationTextComponent("effortlessbuilding.screen.radial_menu"));
|
super(new TranslationTextComponent("effortlessbuilding.screen.radial_menu"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private float clampVis(final float f) {
|
|
||||||
return Math.max(0.0f, Math.min(1.0f, f));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void raiseVisibility() {
|
|
||||||
visibility = clampVis(visibility + lastChange.elapsed(TimeUnit.MILLISECONDS) * TIME_SCALE);
|
|
||||||
lastChange = Stopwatch.createStarted();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void decreaseVisibility() {
|
|
||||||
visibility = clampVis(visibility - lastChange.elapsed(TimeUnit.MILLISECONDS) * TIME_SCALE);
|
|
||||||
lastChange = Stopwatch.createStarted();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVisibility(float visibility) {
|
|
||||||
this.visibility = visibility;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isVisible() {
|
public boolean isVisible() {
|
||||||
return visibility > 0.001;
|
return Minecraft.getInstance().screen instanceof RadialMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void configure(final int scaledWidth, final int scaledHeight) {
|
@Override
|
||||||
Minecraft mc = Minecraft.getInstance();
|
protected void init() {
|
||||||
font = mc.font;
|
super.init();
|
||||||
width = scaledWidth;
|
performedActionUsingMouse = false;
|
||||||
height = scaledHeight;
|
visibility = 0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tick() {
|
||||||
|
super.tick();
|
||||||
|
|
||||||
|
if (!ClientProxy.isKeybindDown(2)) {
|
||||||
|
onClose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(MatrixStack ms, final int mouseX, final int mouseY, final float partialTicks) {
|
public void render(MatrixStack ms, final int mouseX, final int mouseY, final float partialTicks) {
|
||||||
if (!isVisible()) return;
|
BuildModeEnum currentBuildMode = ModeSettingsManager.getModeSettings(minecraft.player).getBuildMode();
|
||||||
|
|
||||||
BuildModeEnum currentBuildMode = ModeSettingsManager.getModeSettings(Minecraft.getInstance().player).getBuildMode();
|
|
||||||
|
|
||||||
RenderSystem.pushMatrix();
|
RenderSystem.pushMatrix();
|
||||||
RenderSystem.translatef(0.0F, 0.0F, 200.0F);
|
RenderSystem.translatef(0.0F, 0.0F, 200.0F);
|
||||||
|
|
||||||
|
visibility += fadeSpeed * partialTicks;
|
||||||
|
if (visibility > 1f) visibility = 1f;
|
||||||
|
|
||||||
final int startColor = (int) (visibility * 98) << 24;
|
final int startColor = (int) (visibility * 98) << 24;
|
||||||
final int endColor = (int) (visibility * 128) << 24;
|
final int endColor = (int) (visibility * 128) << 24;
|
||||||
|
|
||||||
@@ -121,10 +138,6 @@ public class RadialMenu extends Screen {
|
|||||||
final double mouseYCenter = mouseYY - middleY;
|
final double mouseYCenter = mouseYY - middleY;
|
||||||
double mouseRadians = Math.atan2(mouseYCenter, mouseXCenter);
|
double mouseRadians = Math.atan2(mouseYCenter, mouseXCenter);
|
||||||
|
|
||||||
final double ringInnerEdge = 30;
|
|
||||||
final double ringOuterEdge = 65;
|
|
||||||
final double textDistance = 75;
|
|
||||||
final double buttonDistance = 105;
|
|
||||||
final double quarterCircle = Math.PI / 2.0;
|
final double quarterCircle = Math.PI / 2.0;
|
||||||
|
|
||||||
if (mouseRadians < -quarterCircle) {
|
if (mouseRadians < -quarterCircle) {
|
||||||
@@ -142,9 +155,9 @@ public class RadialMenu extends Screen {
|
|||||||
//Add actions
|
//Add actions
|
||||||
buttons.add(new MenuButton(ActionEnum.UNDO.name, ActionEnum.UNDO, -buttonDistance - 26, -13, Direction.UP));
|
buttons.add(new MenuButton(ActionEnum.UNDO.name, ActionEnum.UNDO, -buttonDistance - 26, -13, Direction.UP));
|
||||||
buttons.add(new MenuButton(ActionEnum.REDO.name, ActionEnum.REDO, -buttonDistance, -13, Direction.UP));
|
buttons.add(new MenuButton(ActionEnum.REDO.name, ActionEnum.REDO, -buttonDistance, -13, Direction.UP));
|
||||||
buttons.add(new MenuButton(ActionEnum.OPEN_PLAYER_SETTINGS.name, ActionEnum.OPEN_PLAYER_SETTINGS, -buttonDistance - 26 - 13, 13, Direction.DOWN));
|
// buttons.add(new MenuButton(ActionEnum.OPEN_PLAYER_SETTINGS.name, ActionEnum.OPEN_PLAYER_SETTINGS, -buttonDistance - 26 - 13, 13, Direction.DOWN));
|
||||||
buttons.add(new MenuButton(ActionEnum.OPEN_MODIFIER_SETTINGS.name, ActionEnum.OPEN_MODIFIER_SETTINGS, -buttonDistance - 13, 13, Direction.DOWN));
|
buttons.add(new MenuButton(ActionEnum.OPEN_MODIFIER_SETTINGS.name, ActionEnum.OPEN_MODIFIER_SETTINGS, -buttonDistance - 26, 13, Direction.DOWN));
|
||||||
buttons.add(new MenuButton(ActionEnum.REPLACE.name, ActionEnum.REPLACE, -buttonDistance + 13, 13, Direction.DOWN));
|
buttons.add(new MenuButton(ActionEnum.REPLACE.name, ActionEnum.REPLACE, -buttonDistance, 13, Direction.DOWN));
|
||||||
|
|
||||||
//Add buildmode dependent options
|
//Add buildmode dependent options
|
||||||
OptionEnum[] options = currentBuildMode.options;
|
OptionEnum[] options = currentBuildMode.options;
|
||||||
@@ -159,17 +172,35 @@ public class RadialMenu extends Screen {
|
|||||||
doAction = null;
|
doAction = null;
|
||||||
|
|
||||||
//Draw buildmode backgrounds
|
//Draw buildmode backgrounds
|
||||||
|
drawRadialButtonBackgrounds(currentBuildMode, buffer, middleX, middleY, mouseXCenter, mouseYCenter, mouseRadians,
|
||||||
|
quarterCircle, modes);
|
||||||
|
|
||||||
|
//Draw action backgrounds
|
||||||
|
drawSideButtonBackgrounds(buffer, middleX, middleY, mouseXCenter, mouseYCenter, buttons);
|
||||||
|
|
||||||
|
tessellator.end();
|
||||||
|
|
||||||
|
drawIcons(buffer, middleX, middleY, mc, modes, buttons);
|
||||||
|
|
||||||
|
tessellator.end();
|
||||||
|
|
||||||
|
drawTexts(ms, currentBuildMode, middleX, middleY, modes, buttons, options);
|
||||||
|
|
||||||
|
RenderSystem.popMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawRadialButtonBackgrounds(BuildModeEnum currentBuildMode, BufferBuilder buffer, double middleX, double middleY,
|
||||||
|
double mouseXCenter, double mouseYCenter, double mouseRadians, double quarterCircle, ArrayList<MenuRegion> modes) {
|
||||||
if (!modes.isEmpty()) {
|
if (!modes.isEmpty()) {
|
||||||
final int totalModes = Math.max(3, modes.size());
|
final int totalModes = Math.max(3, modes.size());
|
||||||
int currentMode = 0;
|
|
||||||
final double fragment = Math.PI * 0.005;
|
final double fragment = Math.PI * 0.005;
|
||||||
final double fragment2 = Math.PI * 0.0025;
|
final double fragment2 = Math.PI * 0.0025;
|
||||||
final double perObject = 2.0 * Math.PI / totalModes;
|
final double perObject = 2.0 * Math.PI / totalModes;
|
||||||
|
|
||||||
for (int i = 0; i < modes.size(); i++) {
|
for (int i = 0; i < modes.size(); i++) {
|
||||||
MenuRegion menuRegion = modes.get(i);
|
MenuRegion menuRegion = modes.get(i);
|
||||||
final double beginRadians = currentMode * perObject - quarterCircle;
|
final double beginRadians = i * perObject - quarterCircle;
|
||||||
final double endRadians = (currentMode + 1) * perObject - quarterCircle;
|
final double endRadians = (i + 1) * perObject - quarterCircle;
|
||||||
|
|
||||||
menuRegion.x1 = Math.cos(beginRadians);
|
menuRegion.x1 = Math.cos(beginRadians);
|
||||||
menuRegion.x2 = Math.cos(endRadians);
|
menuRegion.x2 = Math.cos(endRadians);
|
||||||
@@ -186,81 +217,74 @@ public class RadialMenu extends Screen {
|
|||||||
final double y1m2 = Math.sin(beginRadians + fragment2) * ringOuterEdge;
|
final double y1m2 = Math.sin(beginRadians + fragment2) * ringOuterEdge;
|
||||||
final double y2m2 = Math.sin(endRadians - fragment2) * ringOuterEdge;
|
final double y2m2 = Math.sin(endRadians - fragment2) * ringOuterEdge;
|
||||||
|
|
||||||
float r = 0.0f;
|
final boolean isSelected = currentBuildMode.ordinal() == i;
|
||||||
float g = 0.0f;
|
|
||||||
float b = 0.0f;
|
|
||||||
float a = 0.5f;
|
|
||||||
|
|
||||||
//check if current mode
|
|
||||||
int buildMode = currentBuildMode.ordinal();
|
|
||||||
if (buildMode == i) {
|
|
||||||
r = 0f;
|
|
||||||
g = 0.5f;
|
|
||||||
b = 1f;
|
|
||||||
a = 0.5f;
|
|
||||||
//menuRegion.highlighted = true; //draw text
|
|
||||||
}
|
|
||||||
|
|
||||||
//check if mouse is over this region
|
|
||||||
final boolean isMouseInQuad = inTriangle(x1m1, y1m1, x2m2, y2m2, x2m1, y2m1, mouseXCenter, mouseYCenter)
|
final boolean isMouseInQuad = inTriangle(x1m1, y1m1, x2m2, y2m2, x2m1, y2m1, mouseXCenter, mouseYCenter)
|
||||||
|| inTriangle(x1m1, y1m1, x1m2, y1m2, x2m2, y2m2, mouseXCenter, mouseYCenter);
|
|| inTriangle(x1m1, y1m1, x1m2, y1m2, x2m2, y2m2, mouseXCenter, mouseYCenter);
|
||||||
|
final boolean isHighlighted = beginRadians <= mouseRadians && mouseRadians <= endRadians && isMouseInQuad;
|
||||||
|
|
||||||
if (beginRadians <= mouseRadians && mouseRadians <= endRadians && isMouseInQuad) {
|
Vector4f color = radialButtonColor;
|
||||||
r = 0.6f;
|
if (isSelected) color = selectedColor;
|
||||||
g = 0.8f;
|
if (isHighlighted) color = highlightColor;
|
||||||
b = 1f;
|
if (isSelected && isHighlighted) color = highlightSelectedColor;
|
||||||
a = 0.6f;
|
|
||||||
|
if (isHighlighted) {
|
||||||
menuRegion.highlighted = true;
|
menuRegion.highlighted = true;
|
||||||
switchTo = menuRegion.mode;
|
switchTo = menuRegion.mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer.vertex(middleX + x1m1, middleY + y1m1, getBlitOffset()).color(r, g, b, a).endVertex();
|
buffer.vertex(middleX + x1m1, middleY + y1m1, getBlitOffset()).color(color.x(), color.y(), color.z(), color.w()).endVertex();
|
||||||
buffer.vertex(middleX + x2m1, middleY + y2m1, getBlitOffset()).color(r, g, b, a).endVertex();
|
buffer.vertex(middleX + x2m1, middleY + y2m1, getBlitOffset()).color(color.x(), color.y(), color.z(), color.w()).endVertex();
|
||||||
buffer.vertex(middleX + x2m2, middleY + y2m2, getBlitOffset()).color(r, g, b, a).endVertex();
|
buffer.vertex(middleX + x2m2, middleY + y2m2, getBlitOffset()).color(color.x(), color.y(), color.z(), color.w()).endVertex();
|
||||||
buffer.vertex(middleX + x1m2, middleY + y1m2, getBlitOffset()).color(r, g, b, a).endVertex();
|
buffer.vertex(middleX + x1m2, middleY + y1m2, getBlitOffset()).color(color.x(), color.y(), color.z(), color.w()).endVertex();
|
||||||
|
|
||||||
currentMode++;
|
//Category line
|
||||||
|
color = menuRegion.mode.category.color;
|
||||||
|
final double categoryLineOuterEdge = ringInnerEdge + categoryLineWidth;
|
||||||
|
|
||||||
|
final double x1m3 = Math.cos(beginRadians + fragment) * categoryLineOuterEdge;
|
||||||
|
final double y1m3 = Math.sin(beginRadians + fragment) * categoryLineOuterEdge;
|
||||||
|
final double x2m3 = Math.cos(endRadians - fragment) * categoryLineOuterEdge;
|
||||||
|
final double y2m3 = Math.sin(endRadians - fragment) * categoryLineOuterEdge;
|
||||||
|
|
||||||
|
buffer.vertex(middleX + x1m1, middleY + y1m1, getBlitOffset()).color(color.x(), color.y(), color.z(), color.w()).endVertex();
|
||||||
|
buffer.vertex(middleX + x2m1, middleY + y2m1, getBlitOffset()).color(color.x(), color.y(), color.z(), color.w()).endVertex();
|
||||||
|
buffer.vertex(middleX + x2m3, middleY + y2m3, getBlitOffset()).color(color.x(), color.y(), color.z(), color.w()).endVertex();
|
||||||
|
buffer.vertex(middleX + x1m3, middleY + y1m3, getBlitOffset()).color(color.x(), color.y(), color.z(), color.w()).endVertex();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Draw action backgrounds
|
private void drawSideButtonBackgrounds(BufferBuilder buffer, double middleX, double middleY, double mouseXCenter, double mouseYCenter, ArrayList<MenuButton> buttons) {
|
||||||
for (final MenuButton btn : buttons) {
|
for (final MenuButton btn : buttons) {
|
||||||
float r = 0.5f;
|
|
||||||
float g = 0.5f;
|
|
||||||
float b = 0.5f;
|
|
||||||
float a = 0.5f;
|
|
||||||
|
|
||||||
//highlight when active option
|
final boolean isSelected =
|
||||||
if (btn.action == getBuildSpeed() ||
|
btn.action == getBuildSpeed() ||
|
||||||
btn.action == getFill() ||
|
btn.action == getFill() ||
|
||||||
btn.action == getCubeFill() ||
|
btn.action == getCubeFill() ||
|
||||||
btn.action == getRaisedEdge() ||
|
btn.action == getRaisedEdge() ||
|
||||||
btn.action == getLineThickness() ||
|
btn.action == getLineThickness() ||
|
||||||
btn.action == getCircleStart()) {
|
btn.action == getCircleStart();
|
||||||
r = 0.0f;
|
|
||||||
g = 0.5f;
|
|
||||||
b = 1f;
|
|
||||||
a = 0.6f;
|
|
||||||
}
|
|
||||||
|
|
||||||
//highlight when mouse over
|
final boolean isHighlighted = btn.x1 <= mouseXCenter && btn.x2 >= mouseXCenter && btn.y1 <= mouseYCenter && btn.y2 >= mouseYCenter;
|
||||||
if (btn.x1 <= mouseXCenter && btn.x2 >= mouseXCenter && btn.y1 <= mouseYCenter && btn.y2 >= mouseYCenter) {
|
|
||||||
r = 0.6f;
|
Vector4f color = sideButtonColor;
|
||||||
g = 0.8f;
|
if (isSelected) color = selectedColor;
|
||||||
b = 1f;
|
if (isHighlighted) color = highlightColor;
|
||||||
a = 0.6f;
|
if (isSelected && isHighlighted) color = highlightSelectedColor;
|
||||||
|
|
||||||
|
if (isHighlighted) {
|
||||||
btn.highlighted = true;
|
btn.highlighted = true;
|
||||||
doAction = btn.action;
|
doAction = btn.action;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer.vertex(middleX + btn.x1, middleY + btn.y1, getBlitOffset()).color(r, g, b, a).endVertex();
|
buffer.vertex(middleX + btn.x1, middleY + btn.y1, getBlitOffset()).color(color.x(), color.y(), color.z(), color.w()).endVertex();
|
||||||
buffer.vertex(middleX + btn.x1, middleY + btn.y2, getBlitOffset()).color(r, g, b, a).endVertex();
|
buffer.vertex(middleX + btn.x1, middleY + btn.y2, getBlitOffset()).color(color.x(), color.y(), color.z(), color.w()).endVertex();
|
||||||
buffer.vertex(middleX + btn.x2, middleY + btn.y2, getBlitOffset()).color(r, g, b, a).endVertex();
|
buffer.vertex(middleX + btn.x2, middleY + btn.y2, getBlitOffset()).color(color.x(), color.y(), color.z(), color.w()).endVertex();
|
||||||
buffer.vertex(middleX + btn.x2, middleY + btn.y1, getBlitOffset()).color(r, g, b, a).endVertex();
|
buffer.vertex(middleX + btn.x2, middleY + btn.y1, getBlitOffset()).color(color.x(), color.y(), color.z(), color.w()).endVertex();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tessellator.end();
|
private void drawIcons(BufferBuilder buffer, double middleX, double middleY, Minecraft mc, ArrayList<MenuRegion> modes, ArrayList<MenuButton> buttons) {
|
||||||
|
|
||||||
RenderSystem.shadeModel(GL11.GL_FLAT);
|
RenderSystem.shadeModel(GL11.GL_FLAT);
|
||||||
|
|
||||||
RenderSystem.translatef(0f, 0f, 5f);
|
RenderSystem.translatef(0f, 0f, 5f);
|
||||||
@@ -275,8 +299,8 @@ public class RadialMenu extends Screen {
|
|||||||
//Draw buildmode icons
|
//Draw buildmode icons
|
||||||
for (final MenuRegion menuRegion : modes) {
|
for (final MenuRegion menuRegion : modes) {
|
||||||
|
|
||||||
final double x = (menuRegion.x1 + menuRegion.x2) * 0.5 * (ringOuterEdge * 0.6 + 0.4 * ringInnerEdge);
|
final double x = (menuRegion.x1 + menuRegion.x2) * 0.5 * (ringOuterEdge * 0.55 + 0.45 * ringInnerEdge);
|
||||||
final double y = (menuRegion.y1 + menuRegion.y2) * 0.5 * (ringOuterEdge * 0.6 + 0.4 * ringInnerEdge);
|
final double y = (menuRegion.y1 + menuRegion.y2) * 0.5 * (ringOuterEdge * 0.55 + 0.45 * ringInnerEdge);
|
||||||
|
|
||||||
final TextureAtlasSprite sprite = ModClientEventHandler.getBuildModeIcon(menuRegion.mode);
|
final TextureAtlasSprite sprite = ModClientEventHandler.getBuildModeIcon(menuRegion.mode);
|
||||||
|
|
||||||
@@ -324,20 +348,19 @@ public class RadialMenu extends Screen {
|
|||||||
buffer.vertex(middleX + btnx2, middleY + btny2, getBlitOffset()).uv(sprite.getU(u2), sprite.getV(v2)).color(f, f, f, a).endVertex();
|
buffer.vertex(middleX + btnx2, middleY + btny2, getBlitOffset()).uv(sprite.getU(u2), sprite.getV(v2)).color(f, f, f, a).endVertex();
|
||||||
buffer.vertex(middleX + btnx2, middleY + btny1, getBlitOffset()).uv(sprite.getU(u2), sprite.getV(v1)).color(f, f, f, a).endVertex();
|
buffer.vertex(middleX + btnx2, middleY + btny1, getBlitOffset()).uv(sprite.getU(u2), sprite.getV(v1)).color(f, f, f, a).endVertex();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tessellator.end();
|
private void drawTexts(MatrixStack ms, BuildModeEnum currentBuildMode, double middleX, double middleY, ArrayList<MenuRegion> modes, ArrayList<MenuButton> buttons, OptionEnum[] options) {
|
||||||
|
|
||||||
//Draw strings
|
|
||||||
//font.drawStringWithShadow("Actions", (int) (middleX - buttonDistance - 13) - font.getStringWidth("Actions") * 0.5f, (int) middleY - 38, 0xffffffff);
|
//font.drawStringWithShadow("Actions", (int) (middleX - buttonDistance - 13) - font.getStringWidth("Actions") * 0.5f, (int) middleY - 38, 0xffffffff);
|
||||||
|
|
||||||
//Draw option strings
|
//Draw option strings
|
||||||
for (int i = 0; i < currentBuildMode.options.length; i++) {
|
for (int i = 0; i < currentBuildMode.options.length; i++) {
|
||||||
OptionEnum option = options[i];
|
OptionEnum option = options[i];
|
||||||
font.drawShadow(ms, I18n.get(option.name), (int) (middleX + buttonDistance - 9), (int) middleY - 37 + i * 39, 0xeeeeeeff);
|
font.drawShadow(ms, I18n.get(option.name), (int) (middleX + buttonDistance - 9), (int) middleY - 37 + i * 39, optionTextColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
String credits = "Effortless Building";
|
String credits = "Effortless Building";
|
||||||
font.drawShadow(ms, credits, width - font.width(credits) - 4, height - 10, 0x88888888);
|
font.drawShadow(ms, credits, width - font.width(credits) - 4, height - 10, watermarkTextColor);
|
||||||
|
|
||||||
//Draw buildmode text
|
//Draw buildmode text
|
||||||
for (final MenuRegion menuRegion : modes) {
|
for (final MenuRegion menuRegion : modes) {
|
||||||
@@ -348,7 +371,7 @@ public class RadialMenu extends Screen {
|
|||||||
|
|
||||||
int fixed_x = (int) (x * textDistance);
|
int fixed_x = (int) (x * textDistance);
|
||||||
final int fixed_y = (int) (y * textDistance) - font.lineHeight / 2;
|
final int fixed_y = (int) (y * textDistance) - font.lineHeight / 2;
|
||||||
final String text = I18n.get(menuRegion.mode.name);
|
String text = I18n.get(menuRegion.mode.getNameKey());
|
||||||
|
|
||||||
if (x <= -0.2) {
|
if (x <= -0.2) {
|
||||||
fixed_x -= font.width(text);
|
fixed_x -= font.width(text);
|
||||||
@@ -356,7 +379,11 @@ public class RadialMenu extends Screen {
|
|||||||
fixed_x -= font.width(text) / 2;
|
fixed_x -= font.width(text) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
font.drawShadow(ms, text, (int) middleX + fixed_x, (int) middleY + fixed_y, 0xffffffff);
|
font.drawShadow(ms, text, (int) middleX + fixed_x, (int) middleY + fixed_y, whiteTextColor);
|
||||||
|
|
||||||
|
//Draw description
|
||||||
|
text = I18n.get(menuRegion.mode.getDescriptionKey());
|
||||||
|
font.drawShadow(ms, text, (int) middleX - font.width(text) / 2f, (int) middleY + descriptionHeight, descriptionTextColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -364,66 +391,71 @@ public class RadialMenu extends Screen {
|
|||||||
for (final MenuButton button : buttons) {
|
for (final MenuButton button : buttons) {
|
||||||
if (button.highlighted) {
|
if (button.highlighted) {
|
||||||
String text = TextFormatting.AQUA + button.name;
|
String text = TextFormatting.AQUA + button.name;
|
||||||
int wrap = 120;
|
|
||||||
String keybind = ""; // FIXME
|
|
||||||
String keybindFormatted = "";
|
|
||||||
|
|
||||||
//Add keybind in brackets
|
//Add keybind in brackets
|
||||||
if (button.action == ActionEnum.UNDO) {
|
String keybind = findKeybind(button, currentBuildMode);
|
||||||
keybind = I18n.get(ClientProxy.keyBindings[4].saveString());
|
String keybindFormatted = "";
|
||||||
}
|
|
||||||
if (button.action == ActionEnum.REDO) {
|
|
||||||
keybind = I18n.get(ClientProxy.keyBindings[5].saveString());
|
|
||||||
}
|
|
||||||
if (button.action == ActionEnum.REPLACE) {
|
|
||||||
keybind = I18n.get(ClientProxy.keyBindings[1].saveString());
|
|
||||||
}
|
|
||||||
if (button.action == ActionEnum.OPEN_MODIFIER_SETTINGS) {
|
|
||||||
keybind = I18n.get(ClientProxy.keyBindings[0].saveString());
|
|
||||||
}
|
|
||||||
if (currentBuildMode.options.length > 0) {
|
|
||||||
//Add (ctrl) to first two actions of first option
|
|
||||||
if (button.action == currentBuildMode.options[0].actions[0]
|
|
||||||
|| button.action == currentBuildMode.options[0].actions[1]) {
|
|
||||||
keybind = I18n.get(ClientProxy.keyBindings[6].saveString());
|
|
||||||
if (keybind.equals("Left Control")) keybind = "Ctrl";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!keybind.isEmpty())
|
if (!keybind.isEmpty())
|
||||||
keybindFormatted = TextFormatting.GRAY + "(" + WordUtils.capitalizeFully(keybind) + ")";
|
keybindFormatted = TextFormatting.GRAY + "(" + WordUtils.capitalizeFully(keybind) + ")";
|
||||||
|
|
||||||
if (button.textSide == Direction.WEST) {
|
if (button.textSide == Direction.WEST) {
|
||||||
|
|
||||||
font.draw(ms, text, (int) (middleX + button.x1 - 8) - font.width(text),
|
font.draw(ms, text, (int) (middleX + button.x1 - 8) - font.width(text),
|
||||||
(int) (middleY + button.y1 + 6), 0xffffffff);
|
(int) (middleY + button.y1 + 6), whiteTextColor);
|
||||||
|
|
||||||
} else if (button.textSide == Direction.EAST) {
|
} else if (button.textSide == Direction.EAST) {
|
||||||
|
|
||||||
font.draw(ms, text, (int) (middleX + button.x2 + 8),
|
font.draw(ms, text, (int) (middleX + button.x2 + 8),
|
||||||
(int) (middleY + button.y1 + 6), 0xffffffff);
|
(int) (middleY + button.y1 + 6), whiteTextColor);
|
||||||
|
|
||||||
} else if (button.textSide == Direction.UP || button.textSide == Direction.NORTH) {
|
} else if (button.textSide == Direction.UP || button.textSide == Direction.NORTH) {
|
||||||
|
|
||||||
font.draw(ms, keybindFormatted, (int) (middleX + (button.x1 + button.x2) * 0.5 - font.width(keybindFormatted) * 0.5),
|
font.draw(ms, keybindFormatted, (int) (middleX + (button.x1 + button.x2) * 0.5 - font.width(keybindFormatted) * 0.5),
|
||||||
(int) (middleY + button.y1 - 26), 0xffffffff);
|
(int) (middleY + button.y1 - 26), whiteTextColor);
|
||||||
|
|
||||||
font.draw(ms, text, (int) (middleX + (button.x1 + button.x2) * 0.5 - font.width(text) * 0.5),
|
font.draw(ms, text, (int) (middleX + (button.x1 + button.x2) * 0.5 - font.width(text) * 0.5),
|
||||||
(int) (middleY + button.y1 - 14), 0xffffffff);
|
(int) (middleY + button.y1 - 14), whiteTextColor);
|
||||||
|
|
||||||
} else if (button.textSide == Direction.DOWN || button.textSide == Direction.SOUTH) {
|
} else if (button.textSide == Direction.DOWN || button.textSide == Direction.SOUTH) {
|
||||||
|
|
||||||
font.draw(ms, text, (int) (middleX + (button.x1 + button.x2) * 0.5 - font.width(text) * 0.5),
|
font.draw(ms, text, (int) (middleX + (button.x1 + button.x2) * 0.5 - font.width(text) * 0.5),
|
||||||
(int) (middleY + button.y1 + 26), 0xffffffff);
|
(int) (middleY + button.y1 + 26), whiteTextColor);
|
||||||
|
|
||||||
font.draw(ms, keybindFormatted, (int) (middleX + (button.x1 + button.x2) * 0.5 - font.width(keybindFormatted) * 0.5),
|
font.draw(ms, keybindFormatted, (int) (middleX + (button.x1 + button.x2) * 0.5 - font.width(keybindFormatted) * 0.5),
|
||||||
(int) (middleY + button.y1 + 38), 0xffffffff);
|
(int) (middleY + button.y1 + 38), whiteTextColor);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RenderSystem.popMatrix();
|
private String findKeybind(MenuButton button, BuildModeEnum currentBuildMode){
|
||||||
|
String result = "";
|
||||||
|
int keybindingIndex = -1;
|
||||||
|
if (button.action == ActionEnum.UNDO) keybindingIndex = 3;
|
||||||
|
if (button.action == ActionEnum.REDO) keybindingIndex = 4;
|
||||||
|
if (button.action == ActionEnum.REPLACE) keybindingIndex = 1;
|
||||||
|
if (button.action == ActionEnum.OPEN_MODIFIER_SETTINGS) keybindingIndex = 0;
|
||||||
|
|
||||||
|
if (keybindingIndex != -1) {
|
||||||
|
KeyBinding keyMap = ClientProxy.keyBindings[keybindingIndex];
|
||||||
|
|
||||||
|
if (!keyMap.getKeyModifier().name().equals("none")) {
|
||||||
|
result = keyMap.getKeyModifier().name() + " ";
|
||||||
|
}
|
||||||
|
result += I18n.get(keyMap.getKey().getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentBuildMode.options.length > 0) {
|
||||||
|
//Add (ctrl) to first two actions of first option
|
||||||
|
if (button.action == currentBuildMode.options[0].actions[0]
|
||||||
|
|| button.action == currentBuildMode.options[0].actions[1]) {
|
||||||
|
result = I18n.get(ClientProxy.keyBindings[5].getKey().getName());
|
||||||
|
if (result.equals("Left Control")) result = "Ctrl";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean inTriangle(final double x1, final double y1, final double x2, final double y2,
|
private boolean inTriangle(final double x1, final double y1, final double x2, final double y2,
|
||||||
@@ -438,26 +470,62 @@ public class RadialMenu extends Screen {
|
|||||||
return n > 0 ? 1 : -1;
|
return n > 0 ? 1 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
|
public boolean isPauseScreen() {
|
||||||
*/
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
|
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
|
||||||
EffortlessBuilding.log("mouse clicked");
|
performAction(true);
|
||||||
|
|
||||||
KeyBinding.setAll();
|
|
||||||
KeyBinding.set(ClientProxy.keyBindings[3].getKey(), true);
|
|
||||||
|
|
||||||
if (mouseButton == 0) {
|
|
||||||
this.minecraft.setScreen(null);
|
|
||||||
|
|
||||||
if (this.minecraft.screen == null) {
|
|
||||||
this.minecraft.setWindowActive(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return super.mouseClicked(mouseX, mouseY, mouseButton);
|
return super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClose() {
|
||||||
|
super.onClose();
|
||||||
|
//After onClose so it can open another screen
|
||||||
|
if (!performedActionUsingMouse) performAction(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void performAction(boolean fromMouseClick) {
|
||||||
|
PlayerEntity player = Minecraft.getInstance().player;
|
||||||
|
|
||||||
|
ModeSettingsManager.ModeSettings modeSettings = ModeSettingsManager.getModeSettings(player);
|
||||||
|
|
||||||
|
if (switchTo != null) {
|
||||||
|
playRadialMenuSound();
|
||||||
|
|
||||||
|
modeSettings.setBuildMode(switchTo);
|
||||||
|
ModeSettingsManager.setModeSettings(player, modeSettings);
|
||||||
|
PacketHandler.INSTANCE.sendToServer(new ModeSettingsMessage(modeSettings));
|
||||||
|
|
||||||
|
EffortlessBuilding.log(player, I18n.get(modeSettings.getBuildMode().getNameKey()), true);
|
||||||
|
|
||||||
|
if (fromMouseClick) performedActionUsingMouse = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Perform button action
|
||||||
|
ModeOptions.ActionEnum action = doAction;
|
||||||
|
if (action != null) {
|
||||||
|
playRadialMenuSound();
|
||||||
|
|
||||||
|
ModeOptions.performAction(player, action);
|
||||||
|
PacketHandler.INSTANCE.sendToServer(new ModeActionMessage(action));
|
||||||
|
|
||||||
|
if (fromMouseClick) performedActionUsingMouse = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void playRadialMenuSound() {
|
||||||
|
final float volume = 0.1f;
|
||||||
|
if (volume >= 0.0001f) {
|
||||||
|
SimpleSound sound = new SimpleSound(SoundEvents.UI_BUTTON_CLICK, SoundCategory.MASTER, volume, 1.0f, Minecraft.getInstance().player.blockPosition());
|
||||||
|
Minecraft.getInstance().getSoundManager().play(sound);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static class MenuButton {
|
private static class MenuButton {
|
||||||
|
|
||||||
public final ActionEnum action;
|
public final ActionEnum action;
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ public class SurvivalHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!player.isCreative() && Block.byItem(itemstack.getItem()) == block) {
|
if (!player.isCreative() && Block.byItem(itemstack.getItem()) == block) {
|
||||||
CompatHelper.shrinkStack(origstack, itemstack, player);
|
itemstack.shrink(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -0,0 +1,221 @@
|
|||||||
|
package nl.requios.effortlessbuilding.item;
|
||||||
|
|
||||||
|
import mcp.MethodsReturnNonnullByDefault;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.client.util.ITooltipFlag;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
|
import net.minecraft.fluid.Fluids;
|
||||||
|
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||||
|
import net.minecraft.item.*;
|
||||||
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
import net.minecraft.util.ActionResult;
|
||||||
|
import net.minecraft.util.ActionResultType;
|
||||||
|
import net.minecraft.util.Direction;
|
||||||
|
import net.minecraft.util.Hand;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
|
import net.minecraft.util.math.vector.Vector3d;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
|
import net.minecraft.util.text.TextFormatting;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||||
|
import net.minecraftforge.fml.network.NetworkHooks;
|
||||||
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
||||||
|
import nl.requios.effortlessbuilding.buildmode.ModeSettingsManager;
|
||||||
|
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
|
||||||
|
import nl.requios.effortlessbuilding.capability.ItemHandlerCapabilityProvider;
|
||||||
|
import nl.requios.effortlessbuilding.helper.SurvivalHelper;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
@MethodsReturnNonnullByDefault
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
|
public abstract class AbstractRandomizerBagItem extends Item {
|
||||||
|
|
||||||
|
private static long currentSeed = 1337;
|
||||||
|
private static final Random rand = new Random(currentSeed);
|
||||||
|
|
||||||
|
public AbstractRandomizerBagItem() {
|
||||||
|
super(new Item.Properties().tab(ItemGroup.TAB_TOOLS).stacksTo(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract int getInventorySize();
|
||||||
|
|
||||||
|
public abstract INamedContainerProvider getContainerProvider(ItemStack item);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the inventory of a randomizer bag by checking the capability.
|
||||||
|
*/
|
||||||
|
public IItemHandler getBagInventory(ItemStack bag) {
|
||||||
|
return bag.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pick a random slot from the bag. Empty slots will never get chosen.
|
||||||
|
*/
|
||||||
|
public ItemStack pickRandomStack(IItemHandler bagInventory) {
|
||||||
|
//Find how many stacks are non-empty, and save them in a list
|
||||||
|
int nonempty = 0;
|
||||||
|
List<ItemStack> nonEmptyStacks = new ArrayList<>();
|
||||||
|
List<Integer> originalSlots = new ArrayList<>(getInventorySize());
|
||||||
|
for (int i = 0; i < bagInventory.getSlots(); i++) {
|
||||||
|
ItemStack stack = bagInventory.getStackInSlot(i);
|
||||||
|
if (!stack.isEmpty()) {
|
||||||
|
nonempty++;
|
||||||
|
nonEmptyStacks.add(stack);
|
||||||
|
originalSlots.add(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nonEmptyStacks.size() != originalSlots.size())
|
||||||
|
throw new Error("NonEmptyStacks and OriginalSlots not same size");
|
||||||
|
|
||||||
|
if (nonempty == 0) return ItemStack.EMPTY;
|
||||||
|
|
||||||
|
//Pick random slot
|
||||||
|
int randomSlot = rand.nextInt(nonempty);
|
||||||
|
if (randomSlot < 0 || randomSlot > bagInventory.getSlots()) return ItemStack.EMPTY;
|
||||||
|
|
||||||
|
int originalSlot = originalSlots.get(randomSlot);
|
||||||
|
if (originalSlot < 0 || originalSlot > bagInventory.getSlots()) return ItemStack.EMPTY;
|
||||||
|
|
||||||
|
return bagInventory.getStackInSlot(originalSlot);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack findStack(IItemHandler bagInventory, Item item) {
|
||||||
|
for (int i = 0; i < bagInventory.getSlots(); i++) {
|
||||||
|
ItemStack stack = bagInventory.getStackInSlot(i);
|
||||||
|
if (!stack.isEmpty() && stack.getItem() == item) {
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void resetRandomness() {
|
||||||
|
rand.setSeed(currentSeed);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void renewRandomness() {
|
||||||
|
currentSeed = Calendar.getInstance().getTimeInMillis();
|
||||||
|
rand.setSeed(currentSeed);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActionResultType useOn(ItemUseContext ctx) {
|
||||||
|
PlayerEntity player = ctx.getPlayer();
|
||||||
|
World world = ctx.getLevel();
|
||||||
|
BlockPos pos = ctx.getClickedPos();
|
||||||
|
Direction facing = ctx.getClickedFace();
|
||||||
|
ItemStack item = ctx.getItemInHand();
|
||||||
|
Vector3d hitVec = ctx.getClickLocation();
|
||||||
|
|
||||||
|
if (player == null) return ActionResultType.FAIL;
|
||||||
|
|
||||||
|
if (ctx.getPlayer() != null && ctx.getPlayer().isShiftKeyDown()) { //ctx.isPlacerSneaking()
|
||||||
|
if (world.isClientSide) return ActionResultType.SUCCESS;
|
||||||
|
//Open inventory
|
||||||
|
NetworkHooks.openGui((ServerPlayerEntity) player, getContainerProvider(item));
|
||||||
|
} else {
|
||||||
|
if (world.isClientSide) return ActionResultType.SUCCESS;
|
||||||
|
|
||||||
|
//Only place manually if in normal vanilla mode
|
||||||
|
BuildModes.BuildModeEnum buildMode = ModeSettingsManager.getModeSettings(player).getBuildMode();
|
||||||
|
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
|
||||||
|
if (buildMode != BuildModes.BuildModeEnum.NORMAL || modifierSettings.doQuickReplace()) {
|
||||||
|
return ActionResultType.FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Use item
|
||||||
|
//Get bag inventory
|
||||||
|
//TODO offhand support
|
||||||
|
ItemStack bag = player.getItemInHand(Hand.MAIN_HAND);
|
||||||
|
IItemHandler bagInventory = getBagInventory(bag);
|
||||||
|
if (bagInventory == null)
|
||||||
|
return ActionResultType.FAIL;
|
||||||
|
|
||||||
|
ItemStack toPlace = pickRandomStack(bagInventory);
|
||||||
|
if (toPlace.isEmpty()) return ActionResultType.FAIL;
|
||||||
|
|
||||||
|
//Previously: use onItemUse to place block (no synergy)
|
||||||
|
//bag.setItemDamage(toPlace.getMetadata());
|
||||||
|
//toPlace.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ);
|
||||||
|
|
||||||
|
//TODO replaceable
|
||||||
|
if (!world.getBlockState(pos).getBlock().canBeReplaced(world.getBlockState(pos), Fluids.EMPTY)) {
|
||||||
|
pos = pos.relative(facing);
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockItemUseContext blockItemUseContext = new BlockItemUseContext(new ItemUseContext(player, Hand.MAIN_HAND, new BlockRayTraceResult(hitVec, facing, pos, false)));
|
||||||
|
BlockState blockState = Block.byItem(toPlace.getItem()).getStateForPlacement(blockItemUseContext);
|
||||||
|
|
||||||
|
SurvivalHelper.placeBlock(world, player, pos, blockState, toPlace, facing, hitVec, false, false, true);
|
||||||
|
|
||||||
|
//Synergy
|
||||||
|
//Works without calling
|
||||||
|
// 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 ActionResultType.SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
|
||||||
|
ItemStack bag = player.getItemInHand(hand);
|
||||||
|
|
||||||
|
if (player.isShiftKeyDown()) {
|
||||||
|
if (world.isClientSide) return new ActionResult<>(ActionResultType.SUCCESS, bag);
|
||||||
|
//Open inventory
|
||||||
|
NetworkHooks.openGui((ServerPlayerEntity) player, getContainerProvider(bag));
|
||||||
|
} else {
|
||||||
|
//Use item
|
||||||
|
//Get bag inventory
|
||||||
|
IItemHandler bagInventory = getBagInventory(bag);
|
||||||
|
if (bagInventory == null)
|
||||||
|
return new ActionResult<>(ActionResultType.FAIL, bag);
|
||||||
|
|
||||||
|
ItemStack toUse = pickRandomStack(bagInventory);
|
||||||
|
if (toUse.isEmpty()) return new ActionResult<>(ActionResultType.FAIL, bag);
|
||||||
|
|
||||||
|
return toUse.use(world, player, hand);
|
||||||
|
}
|
||||||
|
return new ActionResult<>(ActionResultType.PASS, bag);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getUseDuration(ItemStack p_77626_1_) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundNBT nbt) {
|
||||||
|
return new ItemHandlerCapabilityProvider(getInventorySize());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void appendHoverText(ItemStack stack, @Nullable World world, List<ITextComponent> tooltip, ITooltipFlag flag) {
|
||||||
|
tooltip.add(new StringTextComponent(TextFormatting.BLUE + "Rightclick" + TextFormatting.GRAY + " to place a random block"));
|
||||||
|
tooltip.add(new StringTextComponent(TextFormatting.BLUE + "Sneak + rightclick" + TextFormatting.GRAY + " to open inventory"));
|
||||||
|
if (world != null && world.players().size() > 1) {
|
||||||
|
tooltip.add(new StringTextComponent(TextFormatting.YELLOW + "Experimental on servers: may lose inventory"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescriptionId() {
|
||||||
|
return this.getRegistryName().toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package nl.requios.effortlessbuilding.item;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
|
import net.minecraft.inventory.container.Container;
|
||||||
|
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
|
import nl.requios.effortlessbuilding.gui.DiamondRandomizerBagContainer;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
public class DiamondRandomizerBagItem extends AbstractRandomizerBagItem{
|
||||||
|
public static final int INV_SIZE = 27;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getInventorySize() {
|
||||||
|
return 27;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public INamedContainerProvider getContainerProvider(ItemStack bag) {
|
||||||
|
return new ContainerProvider(bag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ContainerProvider implements INamedContainerProvider {
|
||||||
|
|
||||||
|
private final ItemStack bag;
|
||||||
|
|
||||||
|
public ContainerProvider(ItemStack bag) {
|
||||||
|
this.bag = bag;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ITextComponent getDisplayName() {
|
||||||
|
return new TranslationTextComponent("effortlessbuilding:diamond_randomizer_bag");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public Container createMenu(int containerId, PlayerInventory playerInventory, PlayerEntity player) {
|
||||||
|
return new DiamondRandomizerBagContainer(containerId, playerInventory, ((AbstractRandomizerBagItem)bag.getItem()).getBagInventory(bag));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package nl.requios.effortlessbuilding.item;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
|
import net.minecraft.inventory.container.Container;
|
||||||
|
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
|
import nl.requios.effortlessbuilding.gui.GoldenRandomizerBagContainer;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
public class GoldenRandomizerBagItem extends AbstractRandomizerBagItem{
|
||||||
|
public static final int INV_SIZE = 9;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getInventorySize() {
|
||||||
|
return 9;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public INamedContainerProvider getContainerProvider(ItemStack bag) {
|
||||||
|
return new ContainerProvider(bag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ContainerProvider implements INamedContainerProvider {
|
||||||
|
|
||||||
|
private final ItemStack bag;
|
||||||
|
|
||||||
|
public ContainerProvider(ItemStack bag) {
|
||||||
|
this.bag = bag;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ITextComponent getDisplayName() {
|
||||||
|
return new TranslationTextComponent("effortlessbuilding:golden_randomizer_bag");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public Container createMenu(int containerId, PlayerInventory playerInventory, PlayerEntity player) {
|
||||||
|
return new GoldenRandomizerBagContainer(containerId, playerInventory, ((AbstractRandomizerBagItem)bag.getItem()).getBagInventory(bag));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,251 +0,0 @@
|
|||||||
package nl.requios.effortlessbuilding.item;
|
|
||||||
|
|
||||||
import mcp.MethodsReturnNonnullByDefault;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.client.util.ITooltipFlag;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
|
||||||
import net.minecraft.fluid.Fluids;
|
|
||||||
import net.minecraft.inventory.container.Container;
|
|
||||||
import net.minecraft.inventory.container.INamedContainerProvider;
|
|
||||||
import net.minecraft.item.*;
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
|
||||||
import net.minecraft.util.ActionResult;
|
|
||||||
import net.minecraft.util.ActionResultType;
|
|
||||||
import net.minecraft.util.Direction;
|
|
||||||
import net.minecraft.util.Hand;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.math.BlockRayTraceResult;
|
|
||||||
import net.minecraft.util.math.vector.Vector3d;
|
|
||||||
import net.minecraft.util.text.ITextComponent;
|
|
||||||
import net.minecraft.util.text.StringTextComponent;
|
|
||||||
import net.minecraft.util.text.TextFormatting;
|
|
||||||
import net.minecraft.util.text.TranslationTextComponent;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
|
||||||
import net.minecraftforge.fml.network.NetworkHooks;
|
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
|
||||||
import net.minecraftforge.items.IItemHandler;
|
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
|
||||||
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
|
||||||
import nl.requios.effortlessbuilding.buildmode.ModeSettingsManager;
|
|
||||||
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
|
|
||||||
import nl.requios.effortlessbuilding.capability.ItemHandlerCapabilityProvider;
|
|
||||||
import nl.requios.effortlessbuilding.gui.RandomizerBagContainer;
|
|
||||||
import nl.requios.effortlessbuilding.helper.SurvivalHelper;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
@MethodsReturnNonnullByDefault
|
|
||||||
@ParametersAreNonnullByDefault
|
|
||||||
public class ItemRandomizerBag extends Item {
|
|
||||||
public static final int INV_SIZE = 5;
|
|
||||||
|
|
||||||
private static long currentSeed = 1337;
|
|
||||||
private static final Random rand = new Random(currentSeed);
|
|
||||||
|
|
||||||
public ItemRandomizerBag() {
|
|
||||||
super(new Item.Properties().tab(ItemGroup.TAB_TOOLS).stacksTo(1));
|
|
||||||
|
|
||||||
this.setRegistryName(EffortlessBuilding.MODID, "randomizer_bag");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the inventory of a randomizer bag by checking the capability.
|
|
||||||
*
|
|
||||||
* @param bag
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static IItemHandler getBagInventory(ItemStack bag) {
|
|
||||||
return bag.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Pick a random slot from the bag. Empty slots will never get chosen.
|
|
||||||
*
|
|
||||||
* @param bagInventory
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static ItemStack pickRandomStack(IItemHandler bagInventory) {
|
|
||||||
//Find how many stacks are non-empty, and save them in a list
|
|
||||||
int nonempty = 0;
|
|
||||||
List<ItemStack> nonEmptyStacks = new ArrayList<>(INV_SIZE);
|
|
||||||
List<Integer> originalSlots = new ArrayList<>(INV_SIZE);
|
|
||||||
for (int i = 0; i < bagInventory.getSlots(); i++) {
|
|
||||||
ItemStack stack = bagInventory.getStackInSlot(i);
|
|
||||||
if (!stack.isEmpty()) {
|
|
||||||
nonempty++;
|
|
||||||
nonEmptyStacks.add(stack);
|
|
||||||
originalSlots.add(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nonEmptyStacks.size() != originalSlots.size())
|
|
||||||
throw new Error("NonEmptyStacks and OriginalSlots not same size");
|
|
||||||
|
|
||||||
if (nonempty == 0) return ItemStack.EMPTY;
|
|
||||||
|
|
||||||
//Pick random slot
|
|
||||||
int randomSlot = rand.nextInt(nonempty);
|
|
||||||
if (randomSlot < 0 || randomSlot > bagInventory.getSlots()) return ItemStack.EMPTY;
|
|
||||||
|
|
||||||
int originalSlot = originalSlots.get(randomSlot);
|
|
||||||
if (originalSlot < 0 || originalSlot > bagInventory.getSlots()) return ItemStack.EMPTY;
|
|
||||||
|
|
||||||
return bagInventory.getStackInSlot(originalSlot);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ItemStack findStack(IItemHandler bagInventory, Item item) {
|
|
||||||
for (int i = 0; i < bagInventory.getSlots(); i++) {
|
|
||||||
ItemStack stack = bagInventory.getStackInSlot(i);
|
|
||||||
if (!stack.isEmpty() && stack.getItem() == item) {
|
|
||||||
return stack;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ItemStack.EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void resetRandomness() {
|
|
||||||
rand.setSeed(currentSeed);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void renewRandomness() {
|
|
||||||
currentSeed = Calendar.getInstance().getTimeInMillis();
|
|
||||||
rand.setSeed(currentSeed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ActionResultType useOn(ItemUseContext ctx) {
|
|
||||||
PlayerEntity player = ctx.getPlayer();
|
|
||||||
World world = ctx.getLevel();
|
|
||||||
BlockPos pos = ctx.getClickedPos();
|
|
||||||
Direction facing = ctx.getClickedFace();
|
|
||||||
ItemStack item = ctx.getItemInHand();
|
|
||||||
Vector3d hitVec = ctx.getClickLocation();
|
|
||||||
|
|
||||||
if (player == null) return ActionResultType.FAIL;
|
|
||||||
|
|
||||||
if (ctx.getPlayer() != null && ctx.getPlayer().isShiftKeyDown()) { //ctx.isPlacerSneaking()
|
|
||||||
if (world.isClientSide) return ActionResultType.SUCCESS;
|
|
||||||
//Open inventory
|
|
||||||
NetworkHooks.openGui((ServerPlayerEntity) player, new ContainerProvider(item));
|
|
||||||
} else {
|
|
||||||
if (world.isClientSide) return ActionResultType.SUCCESS;
|
|
||||||
|
|
||||||
//Only place manually if in normal vanilla mode
|
|
||||||
BuildModes.BuildModeEnum buildMode = ModeSettingsManager.getModeSettings(player).getBuildMode();
|
|
||||||
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
|
|
||||||
if (buildMode != BuildModes.BuildModeEnum.NORMAL || modifierSettings.doQuickReplace()) {
|
|
||||||
return ActionResultType.FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Use item
|
|
||||||
//Get bag inventory
|
|
||||||
//TODO offhand support
|
|
||||||
ItemStack bag = player.getItemInHand(Hand.MAIN_HAND);
|
|
||||||
IItemHandler bagInventory = getBagInventory(bag);
|
|
||||||
if (bagInventory == null)
|
|
||||||
return ActionResultType.FAIL;
|
|
||||||
|
|
||||||
ItemStack toPlace = pickRandomStack(bagInventory);
|
|
||||||
if (toPlace.isEmpty()) return ActionResultType.FAIL;
|
|
||||||
|
|
||||||
//Previously: use onItemUse to place block (no synergy)
|
|
||||||
//bag.setItemDamage(toPlace.getMetadata());
|
|
||||||
//toPlace.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ);
|
|
||||||
|
|
||||||
//TODO replaceable
|
|
||||||
if (!world.getBlockState(pos).getBlock().canBeReplaced(world.getBlockState(pos), Fluids.EMPTY)) {
|
|
||||||
pos = pos.relative(facing);
|
|
||||||
}
|
|
||||||
|
|
||||||
BlockItemUseContext blockItemUseContext = new BlockItemUseContext(new ItemUseContext(player, Hand.MAIN_HAND, new BlockRayTraceResult(hitVec, facing, pos, false)));
|
|
||||||
BlockState blockState = Block.byItem(toPlace.getItem()).getStateForPlacement(blockItemUseContext);
|
|
||||||
|
|
||||||
SurvivalHelper.placeBlock(world, player, pos, blockState, toPlace, facing, hitVec, false, false, true);
|
|
||||||
|
|
||||||
//Synergy
|
|
||||||
//Works without calling
|
|
||||||
// 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 ActionResultType.SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
|
|
||||||
ItemStack bag = player.getItemInHand(hand);
|
|
||||||
|
|
||||||
if (player.isShiftKeyDown()) {
|
|
||||||
if (world.isClientSide) return new ActionResult<>(ActionResultType.SUCCESS, bag);
|
|
||||||
//Open inventory
|
|
||||||
NetworkHooks.openGui((ServerPlayerEntity) player, new ContainerProvider(bag));
|
|
||||||
} else {
|
|
||||||
//Use item
|
|
||||||
//Get bag inventory
|
|
||||||
IItemHandler bagInventory = getBagInventory(bag);
|
|
||||||
if (bagInventory == null)
|
|
||||||
return new ActionResult<>(ActionResultType.FAIL, bag);
|
|
||||||
|
|
||||||
ItemStack toUse = pickRandomStack(bagInventory);
|
|
||||||
if (toUse.isEmpty()) return new ActionResult<>(ActionResultType.FAIL, bag);
|
|
||||||
|
|
||||||
return toUse.use(world, player, hand);
|
|
||||||
}
|
|
||||||
return new ActionResult<>(ActionResultType.PASS, bag);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getUseDuration(ItemStack p_77626_1_) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundNBT nbt) {
|
|
||||||
return new ItemHandlerCapabilityProvider();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void appendHoverText(ItemStack stack, @Nullable World world, List<ITextComponent> tooltip, ITooltipFlag flag) {
|
|
||||||
tooltip.add(new StringTextComponent(TextFormatting.BLUE + "Rightclick" + TextFormatting.GRAY + " to place a random block"));
|
|
||||||
tooltip.add(new StringTextComponent(TextFormatting.BLUE + "Sneak + rightclick" + TextFormatting.GRAY + " to open inventory"));
|
|
||||||
if (world != null && world.players().size() > 1) {
|
|
||||||
tooltip.add(new StringTextComponent(TextFormatting.YELLOW + "Experimental on servers: may lose inventory"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDescriptionId() {
|
|
||||||
return this.getRegistryName().toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class ContainerProvider implements INamedContainerProvider {
|
|
||||||
|
|
||||||
private final ItemStack bag;
|
|
||||||
|
|
||||||
public ContainerProvider(ItemStack bag) {
|
|
||||||
this.bag = bag;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ITextComponent getDisplayName() {
|
|
||||||
return new TranslationTextComponent("effortlessbuilding.screen.randomizer_bag");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public Container createMenu(int containerId, PlayerInventory playerInventory, PlayerEntity player) {
|
|
||||||
return new RandomizerBagContainer(containerId, playerInventory, ItemRandomizerBag.getBagInventory(bag));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package nl.requios.effortlessbuilding.item;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
|
import net.minecraft.inventory.container.Container;
|
||||||
|
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
|
import nl.requios.effortlessbuilding.gui.RandomizerBagContainer;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
public class RandomizerBagItem extends AbstractRandomizerBagItem{
|
||||||
|
public static final int INV_SIZE = 5;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getInventorySize() {
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public INamedContainerProvider getContainerProvider(ItemStack bag) {
|
||||||
|
return new ContainerProvider(bag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ContainerProvider implements INamedContainerProvider {
|
||||||
|
|
||||||
|
private final ItemStack bag;
|
||||||
|
|
||||||
|
public ContainerProvider(ItemStack bag) {
|
||||||
|
this.bag = bag;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ITextComponent getDisplayName() {
|
||||||
|
return new TranslationTextComponent("effortlessbuilding:randomizer_bag");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public Container createMenu(int containerId, PlayerInventory playerInventory, PlayerEntity player) {
|
||||||
|
return new RandomizerBagContainer(containerId, playerInventory, ((AbstractRandomizerBagItem)bag.getItem()).getBagInventory(bag));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,11 +22,10 @@ import java.util.List;
|
|||||||
|
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
@MethodsReturnNonnullByDefault
|
@MethodsReturnNonnullByDefault
|
||||||
public class ItemReachUpgrade1 extends Item {
|
public class ReachUpgrade1Item extends Item {
|
||||||
|
|
||||||
public ItemReachUpgrade1() {
|
public ReachUpgrade1Item() {
|
||||||
super(new Item.Properties().tab(ItemGroup.TAB_TOOLS).stacksTo(1));
|
super(new Item.Properties().tab(ItemGroup.TAB_TOOLS).stacksTo(1));
|
||||||
this.setRegistryName(EffortlessBuilding.MODID, "reach_upgrade1");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -22,11 +22,10 @@ import java.util.List;
|
|||||||
|
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
@MethodsReturnNonnullByDefault
|
@MethodsReturnNonnullByDefault
|
||||||
public class ItemReachUpgrade2 extends Item {
|
public class ReachUpgrade2Item extends Item {
|
||||||
|
|
||||||
public ItemReachUpgrade2() {
|
public ReachUpgrade2Item() {
|
||||||
super(new Item.Properties().tab(ItemGroup.TAB_TOOLS).stacksTo(1));
|
super(new Item.Properties().tab(ItemGroup.TAB_TOOLS).stacksTo(1));
|
||||||
this.setRegistryName(EffortlessBuilding.MODID, "reach_upgrade2");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -22,11 +22,10 @@ import java.util.List;
|
|||||||
|
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
@MethodsReturnNonnullByDefault
|
@MethodsReturnNonnullByDefault
|
||||||
public class ItemReachUpgrade3 extends Item {
|
public class ReachUpgrade3Item extends Item {
|
||||||
|
|
||||||
public ItemReachUpgrade3() {
|
public ReachUpgrade3Item() {
|
||||||
super(new Item.Properties().tab(ItemGroup.TAB_TOOLS).stacksTo(1));
|
super(new Item.Properties().tab(ItemGroup.TAB_TOOLS).stacksTo(1));
|
||||||
this.setRegistryName(EffortlessBuilding.MODID, "reach_upgrade3");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -42,6 +42,8 @@ import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
|||||||
import nl.requios.effortlessbuilding.buildmode.ModeSettingsManager;
|
import nl.requios.effortlessbuilding.buildmode.ModeSettingsManager;
|
||||||
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
|
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
|
||||||
import nl.requios.effortlessbuilding.compatibility.CompatHelper;
|
import nl.requios.effortlessbuilding.compatibility.CompatHelper;
|
||||||
|
import nl.requios.effortlessbuilding.gui.DiamondRandomizerBagScreen;
|
||||||
|
import nl.requios.effortlessbuilding.gui.GoldenRandomizerBagScreen;
|
||||||
import nl.requios.effortlessbuilding.gui.RandomizerBagScreen;
|
import nl.requios.effortlessbuilding.gui.RandomizerBagScreen;
|
||||||
import nl.requios.effortlessbuilding.gui.buildmode.PlayerSettingsGui;
|
import nl.requios.effortlessbuilding.gui.buildmode.PlayerSettingsGui;
|
||||||
import nl.requios.effortlessbuilding.gui.buildmode.RadialMenu;
|
import nl.requios.effortlessbuilding.gui.buildmode.RadialMenu;
|
||||||
@@ -66,6 +68,33 @@ public class ClientProxy implements IProxy {
|
|||||||
private static int breakCooldown = 0;
|
private static int breakCooldown = 0;
|
||||||
private static boolean shadersInitialized = false;
|
private static boolean shadersInitialized = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup(FMLCommonSetupEvent event) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clientSetup(FMLClientSetupEvent event) {
|
||||||
|
// register key bindings
|
||||||
|
keyBindings = new KeyBinding[6];
|
||||||
|
|
||||||
|
// instantiate the key bindings
|
||||||
|
keyBindings[0] = new KeyBinding("key.effortlessbuilding.hud.desc", KeyConflictContext.UNIVERSAL, InputMappings.getKey(GLFW.GLFW_KEY_KP_ADD, 0), "key.effortlessbuilding.category");
|
||||||
|
keyBindings[1] = new KeyBinding("key.effortlessbuilding.replace.desc", KeyConflictContext.IN_GAME, InputMappings.getKey(GLFW.GLFW_KEY_KP_SUBTRACT, 0), "key.effortlessbuilding.category");
|
||||||
|
keyBindings[2] = new KeyBinding("key.effortlessbuilding.mode.desc", KeyConflictContext.IN_GAME, InputMappings.getKey(GLFW.GLFW_KEY_LEFT_ALT, 0), "key.effortlessbuilding.category");
|
||||||
|
keyBindings[3] = new KeyBinding("key.effortlessbuilding.undo.desc", KeyConflictContext.IN_GAME, KeyModifier.CONTROL, InputMappings.getKey(GLFW.GLFW_KEY_Z, 0), "key.effortlessbuilding.category");
|
||||||
|
keyBindings[4] = new KeyBinding("key.effortlessbuilding.redo.desc", KeyConflictContext.IN_GAME, KeyModifier.CONTROL, InputMappings.getKey(GLFW.GLFW_KEY_Y, 0), "key.effortlessbuilding.category");
|
||||||
|
keyBindings[5] = new KeyBinding("key.effortlessbuilding.altplacement.desc", KeyConflictContext.IN_GAME, InputMappings.getKey(GLFW.GLFW_KEY_LEFT_CONTROL, 0), "key.effortlessbuilding.category");
|
||||||
|
|
||||||
|
// register all the key bindings
|
||||||
|
for (KeyBinding keyBinding : keyBindings) {
|
||||||
|
ClientRegistry.registerKeyBinding(keyBinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
ScreenManager.register(EffortlessBuilding.RANDOMIZER_BAG_CONTAINER.get(), RandomizerBagScreen::new);
|
||||||
|
ScreenManager.register(EffortlessBuilding.GOLDEN_RANDOMIZER_BAG_CONTAINER.get(), GoldenRandomizerBagScreen::new);
|
||||||
|
ScreenManager.register(EffortlessBuilding.DIAMOND_RANDOMIZER_BAG_CONTAINER.get(), DiamondRandomizerBagScreen::new);
|
||||||
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onClientTick(TickEvent.ClientTickEvent event) {
|
public static void onClientTick(TickEvent.ClientTickEvent event) {
|
||||||
|
|
||||||
@@ -233,31 +262,33 @@ public class ClientProxy implements IProxy {
|
|||||||
PacketHandler.INSTANCE.sendToServer(new ModifierSettingsMessage(modifierSettings));
|
PacketHandler.INSTANCE.sendToServer(new ModifierSettingsMessage(modifierSettings));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Creative/survival mode toggle
|
//Radial menu
|
||||||
if (keyBindings[2].consumeClick()) {
|
if (keyBindings[2].isDown()) {
|
||||||
if (player.isCreative()) {
|
if (ReachHelper.getMaxReach(player) > 0) {
|
||||||
player.chat("/gamemode survival");
|
if (!RadialMenu.instance.isVisible()) {
|
||||||
|
Minecraft.getInstance().setScreen(RadialMenu.instance);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
player.chat("/gamemode creative");
|
EffortlessBuilding.log(player, "Build modes are disabled until your reach has increased. Increase your reach with craftable reach upgrades.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Undo (Ctrl+Z)
|
//Undo (Ctrl+Z)
|
||||||
if (keyBindings[4].consumeClick()) {
|
if (keyBindings[3].consumeClick()) {
|
||||||
ModeOptions.ActionEnum action = ModeOptions.ActionEnum.UNDO;
|
ModeOptions.ActionEnum action = ModeOptions.ActionEnum.UNDO;
|
||||||
ModeOptions.performAction(player, action);
|
ModeOptions.performAction(player, action);
|
||||||
PacketHandler.INSTANCE.sendToServer(new ModeActionMessage(action));
|
PacketHandler.INSTANCE.sendToServer(new ModeActionMessage(action));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Redo (Ctrl+Y)
|
//Redo (Ctrl+Y)
|
||||||
if (keyBindings[5].consumeClick()) {
|
if (keyBindings[4].consumeClick()) {
|
||||||
ModeOptions.ActionEnum action = ModeOptions.ActionEnum.REDO;
|
ModeOptions.ActionEnum action = ModeOptions.ActionEnum.REDO;
|
||||||
ModeOptions.performAction(player, action);
|
ModeOptions.performAction(player, action);
|
||||||
PacketHandler.INSTANCE.sendToServer(new ModeActionMessage(action));
|
PacketHandler.INSTANCE.sendToServer(new ModeActionMessage(action));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Change placement mode
|
//Change placement mode
|
||||||
if (keyBindings[6].consumeClick()) {
|
if (keyBindings[5].consumeClick()) {
|
||||||
//Toggle between first two actions of the first option of the current build mode
|
//Toggle between first two actions of the first option of the current build mode
|
||||||
BuildModes.BuildModeEnum currentBuildMode = ModeSettingsManager.getModeSettings(player).getBuildMode();
|
BuildModes.BuildModeEnum currentBuildMode = ModeSettingsManager.getModeSettings(player).getBuildMode();
|
||||||
if (currentBuildMode.options.length > 0) {
|
if (currentBuildMode.options.length > 0) {
|
||||||
@@ -273,49 +304,24 @@ public class ClientProxy implements IProxy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//For shader development
|
|
||||||
if (keyBindings.length >= 8 && keyBindings[7].consumeClick()) {
|
|
||||||
ShaderHandler.init();
|
|
||||||
EffortlessBuilding.log(player, "Reloaded shaders");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openModifierSettings() {
|
public static void openModifierSettings() {
|
||||||
Minecraft mc = Minecraft.getInstance();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
ClientPlayerEntity player = mc.player;
|
PlayerEntity player = mc.player;
|
||||||
if (player == null)
|
if (player == null) return;
|
||||||
return;
|
|
||||||
|
|
||||||
RadialMenu.instance.setVisibility(0f);
|
|
||||||
|
|
||||||
//Disabled if max reach is 0, might be set in the config that way.
|
//Disabled if max reach is 0, might be set in the config that way.
|
||||||
if (ReachHelper.getMaxReach(player) == 0) {
|
if (ReachHelper.getMaxReach(player) == 0) {
|
||||||
EffortlessBuilding.log(player, "Build modifiers are disabled until your reach has increased. Increase your reach with craftable reach upgrades.");
|
EffortlessBuilding.log(player, "Build modifiers are disabled until your reach has increased. Increase your reach with craftable reach upgrades.");
|
||||||
} else {
|
} else {
|
||||||
if (mc.screen == null) {
|
|
||||||
mc.setScreen(new ModifierSettingsGui());
|
mc.setScreen(new ModifierSettingsGui());
|
||||||
} else {
|
|
||||||
player.closeContainer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openPlayerSettings() {
|
public static void openPlayerSettings() {
|
||||||
Minecraft mc = Minecraft.getInstance();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
ClientPlayerEntity player = mc.player;
|
|
||||||
if (player == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
RadialMenu.instance.setVisibility(0f);
|
|
||||||
|
|
||||||
//Disabled if max reach is 0, might be set in the config that way.
|
|
||||||
if (mc.screen == null) {
|
|
||||||
mc.setScreen(new PlayerSettingsGui());
|
mc.setScreen(new PlayerSettingsGui());
|
||||||
} else {
|
|
||||||
player.closeContainer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
@@ -326,6 +332,12 @@ public class ClientProxy implements IProxy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isKeybindDown(int keybindIndex) {
|
||||||
|
return InputMappings.isKeyDown(
|
||||||
|
Minecraft.getInstance().getWindow().getWindow(),
|
||||||
|
ClientProxy.keyBindings[2].getKey().getValue());
|
||||||
|
}
|
||||||
|
|
||||||
public static RayTraceResult getLookingAt(PlayerEntity player) {
|
public static RayTraceResult getLookingAt(PlayerEntity player) {
|
||||||
World world = player.level;
|
World world = player.level;
|
||||||
|
|
||||||
@@ -340,41 +352,6 @@ public class ClientProxy implements IProxy {
|
|||||||
return world.clip(new RayTraceContext(start, end, RayTraceContext.BlockMode.COLLIDER, RayTraceContext.FluidMode.NONE, player));
|
return world.clip(new RayTraceContext(start, end, RayTraceContext.BlockMode.COLLIDER, RayTraceContext.FluidMode.NONE, player));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setup(FMLCommonSetupEvent event) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clientSetup(FMLClientSetupEvent event) {
|
|
||||||
// register key bindings
|
|
||||||
keyBindings = new KeyBinding[7];
|
|
||||||
|
|
||||||
// instantiate the key bindings
|
|
||||||
keyBindings[0] = new KeyBinding("key.effortlessbuilding.hud.desc", KeyConflictContext.UNIVERSAL, InputMappings.getKey(GLFW.GLFW_KEY_KP_ADD, 0), "key.effortlessbuilding.category");
|
|
||||||
keyBindings[1] = new KeyBinding("key.effortlessbuilding.replace.desc", KeyConflictContext.IN_GAME, InputMappings.getKey(GLFW.GLFW_KEY_KP_SUBTRACT, 0), "key.effortlessbuilding.category");
|
|
||||||
keyBindings[2] = new KeyBinding("key.effortlessbuilding.creative.desc", KeyConflictContext.IN_GAME, InputMappings.getKey(GLFW.GLFW_KEY_F4, 0), "key.effortlessbuilding.category");
|
|
||||||
keyBindings[3] = new KeyBinding("key.effortlessbuilding.mode.desc", KeyConflictContext.IN_GAME, InputMappings.getKey(GLFW.GLFW_KEY_LEFT_ALT, 0), "key.effortlessbuilding.category") {
|
|
||||||
@Override
|
|
||||||
public boolean same(KeyBinding other) {
|
|
||||||
//Does not conflict with Chisels and Bits radial menu
|
|
||||||
if (other.getKey().getValue() == getKey().getValue() && other.getName().equals("mod.chiselsandbits.other.mode"))
|
|
||||||
return false;
|
|
||||||
return super.same(other);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
keyBindings[4] = new KeyBinding("key.effortlessbuilding.undo.desc", KeyConflictContext.IN_GAME, KeyModifier.CONTROL, InputMappings.getKey(GLFW.GLFW_KEY_Z, 0), "key.effortlessbuilding.category");
|
|
||||||
keyBindings[5] = new KeyBinding("key.effortlessbuilding.redo.desc", KeyConflictContext.IN_GAME, KeyModifier.CONTROL, InputMappings.getKey(GLFW.GLFW_KEY_Y, 0), "key.effortlessbuilding.category");
|
|
||||||
keyBindings[6] = new KeyBinding("key.effortlessbuilding.altplacement.desc", KeyConflictContext.IN_GAME, InputMappings.getKey(GLFW.GLFW_KEY_LEFT_CONTROL, 0), "key.effortlessbuilding.category");
|
|
||||||
//keyBindings[7] = new KeyBinding("Reload shaders", KeyConflictContext.UNIVERSAL, InputMappings.getInputByCode(GLFW.GLFW_KEY_TAB, 0), "key.effortlessbuilding.category");
|
|
||||||
|
|
||||||
// register all the key bindings
|
|
||||||
for (KeyBinding keyBinding : keyBindings) {
|
|
||||||
ClientRegistry.registerKeyBinding(keyBinding);
|
|
||||||
}
|
|
||||||
|
|
||||||
DeferredWorkQueue.runLater(() -> ScreenManager.register(EffortlessBuilding.RANDOMIZER_BAG_CONTAINER.get(), RandomizerBagScreen::new));
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlayerEntity getPlayerEntityFromContext(Supplier<NetworkEvent.Context> ctx) {
|
public PlayerEntity getPlayerEntityFromContext(Supplier<NetworkEvent.Context> ctx) {
|
||||||
return (ctx.get().getDirection().getReceptionSide() == LogicalSide.CLIENT ? Minecraft.getInstance().player : ctx.get().getSender());
|
return (ctx.get().getDirection().getReceptionSide() == LogicalSide.CLIENT ? Minecraft.getInstance().player : ctx.get().getSender());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager.Modif
|
|||||||
import nl.requios.effortlessbuilding.compatibility.CompatHelper;
|
import nl.requios.effortlessbuilding.compatibility.CompatHelper;
|
||||||
import nl.requios.effortlessbuilding.helper.ReachHelper;
|
import nl.requios.effortlessbuilding.helper.ReachHelper;
|
||||||
import nl.requios.effortlessbuilding.helper.SurvivalHelper;
|
import nl.requios.effortlessbuilding.helper.SurvivalHelper;
|
||||||
import nl.requios.effortlessbuilding.item.ItemRandomizerBag;
|
import nl.requios.effortlessbuilding.item.RandomizerBagItem;
|
||||||
import nl.requios.effortlessbuilding.proxy.ClientProxy;
|
import nl.requios.effortlessbuilding.proxy.ClientProxy;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -168,7 +168,7 @@ public class BlockPreviewRenderer {
|
|||||||
previousSecondPos = secondPos;
|
previousSecondPos = secondPos;
|
||||||
|
|
||||||
//if so, renew randomness of randomizer bag
|
//if so, renew randomness of randomizer bag
|
||||||
ItemRandomizerBag.renewRandomness();
|
RandomizerBagItem.renewRandomness();
|
||||||
//and play sound (max once every tick)
|
//and play sound (max once every tick)
|
||||||
if (newCoordinates.size() > 1 && blockStates.size() > 1 && soundTime < ClientProxy.ticksInGame - 0) {
|
if (newCoordinates.size() > 1 && blockStates.size() > 1 && soundTime < ClientProxy.ticksInGame - 0) {
|
||||||
soundTime = ClientProxy.ticksInGame;
|
soundTime = ClientProxy.ticksInGame;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import net.minecraft.client.renderer.RenderState;
|
|||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||||
|
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.vector.Vector3d;
|
import net.minecraft.util.math.vector.Vector3d;
|
||||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||||
@@ -14,22 +15,7 @@ import org.lwjgl.opengl.*;
|
|||||||
import java.util.OptionalDouble;
|
import java.util.OptionalDouble;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class BuildRenderTypes {
|
public class BuildRenderTypes extends RenderType {
|
||||||
public static final RenderState.TransparencyState TRANSLUCENT_TRANSPARENCY;
|
|
||||||
public static final RenderState.TransparencyState NO_TRANSPARENCY;
|
|
||||||
|
|
||||||
public static final RenderState.DiffuseLightingState DIFFUSE_LIGHTING_ENABLED;
|
|
||||||
public static final RenderState.DiffuseLightingState DIFFUSE_LIGHTING_DISABLED;
|
|
||||||
|
|
||||||
public static final RenderState.LayerState PROJECTION_LAYERING;
|
|
||||||
|
|
||||||
public static final RenderState.CullState CULL_DISABLED;
|
|
||||||
|
|
||||||
public static final RenderState.AlphaState DEFAULT_ALPHA;
|
|
||||||
|
|
||||||
public static final RenderState.WriteMaskState WRITE_TO_DEPTH_AND_COLOR;
|
|
||||||
public static final RenderState.WriteMaskState COLOR_WRITE;
|
|
||||||
|
|
||||||
public static final RenderType LINES;
|
public static final RenderType LINES;
|
||||||
public static final RenderType PLANES;
|
public static final RenderType PLANES;
|
||||||
|
|
||||||
@@ -37,57 +23,42 @@ public class BuildRenderTypes {
|
|||||||
private static final int secondaryTextureUnit = 2;
|
private static final int secondaryTextureUnit = 2;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
TRANSLUCENT_TRANSPARENCY = ObfuscationReflectionHelper.getPrivateValue(RenderState.class, null, "TRANSLUCENT_TRANSPARENCY");
|
final LineState LINE = new LineState(OptionalDouble.of(2.0));
|
||||||
NO_TRANSPARENCY = ObfuscationReflectionHelper.getPrivateValue(RenderState.class, null, "NO_TRANSPARENCY");
|
|
||||||
|
|
||||||
DIFFUSE_LIGHTING_ENABLED = new RenderState.DiffuseLightingState(true);
|
|
||||||
DIFFUSE_LIGHTING_DISABLED = new RenderState.DiffuseLightingState(false);
|
|
||||||
|
|
||||||
PROJECTION_LAYERING = ObfuscationReflectionHelper.getPrivateValue(RenderState.class, null, "VIEW_OFFSET_Z_LAYERING");
|
|
||||||
|
|
||||||
CULL_DISABLED = new RenderState.CullState(false);
|
|
||||||
|
|
||||||
DEFAULT_ALPHA = new RenderState.AlphaState(0.003921569F);
|
|
||||||
|
|
||||||
final boolean ENABLE_DEPTH_WRITING = true;
|
|
||||||
final boolean ENABLE_COLOUR_COMPONENTS_WRITING = true;
|
|
||||||
WRITE_TO_DEPTH_AND_COLOR = new RenderState.WriteMaskState(ENABLE_COLOUR_COMPONENTS_WRITING, ENABLE_DEPTH_WRITING);
|
|
||||||
COLOR_WRITE = new RenderState.WriteMaskState(true, false);
|
|
||||||
|
|
||||||
final int INITIAL_BUFFER_SIZE = 128;
|
final int INITIAL_BUFFER_SIZE = 128;
|
||||||
RenderType.State renderState;
|
RenderType.State renderState;
|
||||||
|
|
||||||
//LINES
|
//LINES
|
||||||
// RenderSystem.pushLightingAttributes();
|
renderState = State.builder()
|
||||||
// RenderSystem.pushTextureAttributes();
|
.setLineState(LINE)
|
||||||
// RenderSystem.disableCull();
|
.setLayeringState(VIEW_OFFSET_Z_LAYERING)
|
||||||
// RenderSystem.disableLighting();
|
|
||||||
// RenderSystem.disableTexture();
|
|
||||||
//
|
|
||||||
// RenderSystem.enableBlend();
|
|
||||||
// RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
//
|
|
||||||
// RenderSystem.lineWidth(2);
|
|
||||||
renderState = RenderType.State.builder()
|
|
||||||
.setLineState(new RenderState.LineState(OptionalDouble.of(2)))
|
|
||||||
.setLayeringState(PROJECTION_LAYERING)
|
|
||||||
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
|
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
|
||||||
.setWriteMaskState(WRITE_TO_DEPTH_AND_COLOR)
|
.setTextureState(NO_TEXTURE)
|
||||||
.setCullState(CULL_DISABLED)
|
.setDepthTestState(NO_DEPTH_TEST)
|
||||||
|
.setLightmapState(NO_LIGHTMAP)
|
||||||
|
.setWriteMaskState(COLOR_DEPTH_WRITE)
|
||||||
|
.setCullState(NO_CULL)
|
||||||
.createCompositeState(false);
|
.createCompositeState(false);
|
||||||
LINES = RenderType.create("eb_lines",
|
LINES = RenderType.create("eb_lines",
|
||||||
DefaultVertexFormats.POSITION_COLOR, GL11.GL_LINES, INITIAL_BUFFER_SIZE, renderState);
|
DefaultVertexFormats.POSITION_COLOR, GL11.GL_LINES, INITIAL_BUFFER_SIZE, false, false, renderState);
|
||||||
|
|
||||||
renderState = RenderType.State.builder()
|
//PLANES
|
||||||
.setLineState(new RenderState.LineState(OptionalDouble.of(2)))
|
renderState = State.builder()
|
||||||
.setLayeringState(PROJECTION_LAYERING)
|
.setLineState(LINE)
|
||||||
|
.setLayeringState(VIEW_OFFSET_Z_LAYERING)
|
||||||
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
|
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
|
||||||
|
.setTextureState(NO_TEXTURE)
|
||||||
|
.setDepthTestState(NO_DEPTH_TEST)
|
||||||
|
.setLightmapState(NO_LIGHTMAP)
|
||||||
.setWriteMaskState(COLOR_WRITE)
|
.setWriteMaskState(COLOR_WRITE)
|
||||||
.setCullState(CULL_DISABLED)
|
.setCullState(NO_CULL)
|
||||||
.createCompositeState(false);
|
.createCompositeState(false);
|
||||||
PLANES = RenderType.create("eb_planes",
|
PLANES = RenderType.create("eb_planes",
|
||||||
DefaultVertexFormats.POSITION_COLOR, GL11.GL_TRIANGLE_STRIP, INITIAL_BUFFER_SIZE, renderState);
|
DefaultVertexFormats.POSITION_COLOR, GL11.GL_TRIANGLE_STRIP, INITIAL_BUFFER_SIZE, false, false, renderState);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dummy constructor needed to make java happy
|
||||||
|
public BuildRenderTypes(String p_i225992_1_, VertexFormat p_i225992_2_, int p_i225992_3_, int p_i225992_4_, boolean p_i225992_5_, boolean p_i225992_6_, Runnable p_i225992_7_, Runnable p_i225992_8_) {
|
||||||
|
super(p_i225992_1_, p_i225992_2_, p_i225992_3_, p_i225992_4_, p_i225992_5_, p_i225992_6_, p_i225992_7_, p_i225992_8_);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RenderType getBlockPreviewRenderType(float dissolve, BlockPos blockPos, BlockPos firstPos,
|
public static RenderType getBlockPreviewRenderType(float dissolve, BlockPos blockPos, BlockPos firstPos,
|
||||||
@@ -107,7 +78,7 @@ public class BuildRenderTypes {
|
|||||||
//highjacking texturing state (which does nothing by default) to do my own things
|
//highjacking texturing state (which does nothing by default) to do my own things
|
||||||
|
|
||||||
String stateName = "eb_texturing_" + dissolve + "_" + blockPos + "_" + firstPos + "_" + secondPos + "_" + red;
|
String stateName = "eb_texturing_" + dissolve + "_" + blockPos + "_" + firstPos + "_" + secondPos + "_" + red;
|
||||||
RenderState.TexturingState MY_TEXTURING = new RenderState.TexturingState(stateName, () -> {
|
TexturingState MY_TEXTURING = new TexturingState(stateName, () -> {
|
||||||
// RenderSystem.pushLightingAttributes();
|
// RenderSystem.pushLightingAttributes();
|
||||||
// RenderSystem.pushTextureAttributes();
|
// RenderSystem.pushTextureAttributes();
|
||||||
|
|
||||||
@@ -116,14 +87,14 @@ public class BuildRenderTypes {
|
|||||||
}, ShaderHandler::releaseShader);
|
}, ShaderHandler::releaseShader);
|
||||||
|
|
||||||
RenderType.State renderState = RenderType.State.builder()
|
RenderType.State renderState = RenderType.State.builder()
|
||||||
.setTextureState(new RenderState.TextureState(ShaderHandler.shaderMaskTextureLocation, false, false))
|
.setTextureState(new TextureState(ShaderHandler.shaderMaskTextureLocation, false, false))
|
||||||
.setTexturingState(MY_TEXTURING)
|
.setTexturingState(MY_TEXTURING)
|
||||||
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
|
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
|
||||||
.setDiffuseLightingState(DIFFUSE_LIGHTING_DISABLED)
|
.setDiffuseLightingState(NO_DIFFUSE_LIGHTING)
|
||||||
.setAlphaState(DEFAULT_ALPHA)
|
.setAlphaState(DEFAULT_ALPHA)
|
||||||
.setCullState(new RenderState.CullState(true))
|
.setCullState(new CullState(true))
|
||||||
.setLightmapState(new RenderState.LightmapState(false))
|
.setLightmapState(new LightmapState(false))
|
||||||
.setOverlayState(new RenderState.OverlayState(false))
|
.setOverlayState(new OverlayState(false))
|
||||||
.createCompositeState(true);
|
.createCompositeState(true);
|
||||||
//Unique name for every combination, otherwise it will reuse the previous one
|
//Unique name for every combination, otherwise it will reuse the previous one
|
||||||
String name = "eb_block_previews_" + dissolve + "_" + blockPos + "_" + firstPos + "_" + secondPos + "_" + red;
|
String name = "eb_block_previews_" + dissolve + "_" + blockPos + "_" + firstPos + "_" + secondPos + "_" + red;
|
||||||
@@ -198,43 +169,4 @@ public class BuildRenderTypes {
|
|||||||
this.red = red;
|
this.red = red;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// public static class MyTexturingState extends RenderState.TexturingState {
|
|
||||||
//
|
|
||||||
// public float dissolve;
|
|
||||||
// public Vector3d blockPos;
|
|
||||||
// public Vector3d firstPos;
|
|
||||||
// public Vector3d secondPos;
|
|
||||||
// public boolean highlight;
|
|
||||||
// public boolean red;
|
|
||||||
//
|
|
||||||
// public MyTexturingState(String p_i225989_1_, float dissolve, Vector3d blockPos, Vector3d firstPos,
|
|
||||||
// Vector3d secondPos, boolean highlight, boolean red, Runnable p_i225989_2_, Runnable p_i225989_3_) {
|
|
||||||
// super(p_i225989_1_, p_i225989_2_, p_i225989_3_);
|
|
||||||
// this.dissolve = dissolve;
|
|
||||||
// this.blockPos = blockPos;
|
|
||||||
// this.firstPos = firstPos;
|
|
||||||
// this.secondPos = secondPos;
|
|
||||||
// this.highlight = highlight;
|
|
||||||
// this.red = red;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean equals(Object p_equals_1_) {
|
|
||||||
// if (this == p_equals_1_) {
|
|
||||||
// return true;
|
|
||||||
// } else if (p_equals_1_ != null && this.getClass() == p_equals_1_.getClass()) {
|
|
||||||
// MyTexturingState other = (MyTexturingState)p_equals_1_;
|
|
||||||
// return this.dissolve == other.dissolve && this.blockPos == other.blockPos && this.firstPos == other.firstPos
|
|
||||||
// && this.secondPos == other.secondPos && this.highlight == other.highlight && this.red == other.red;
|
|
||||||
// } else {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public int hashCode() {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,36 +4,22 @@ import com.mojang.blaze3d.matrix.MatrixStack;
|
|||||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.audio.SimpleSound;
|
|
||||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
|
||||||
import net.minecraft.client.renderer.*;
|
import net.minecraft.client.renderer.*;
|
||||||
import net.minecraft.client.renderer.model.IBakedModel;
|
import net.minecraft.client.renderer.model.IBakedModel;
|
||||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||||
import net.minecraft.client.resources.I18n;
|
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.util.SoundCategory;
|
|
||||||
import net.minecraft.util.SoundEvents;
|
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.shapes.VoxelShape;
|
import net.minecraft.util.math.shapes.VoxelShape;
|
||||||
import net.minecraft.util.math.vector.Vector3d;
|
import net.minecraft.util.math.vector.Vector3d;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
|
||||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||||
import net.minecraftforge.eventbus.api.EventPriority;
|
import net.minecraftforge.eventbus.api.EventPriority;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||||
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
|
||||||
import nl.requios.effortlessbuilding.buildmode.ModeSettingsManager;
|
import nl.requios.effortlessbuilding.buildmode.ModeSettingsManager;
|
||||||
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
|
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
|
||||||
import nl.requios.effortlessbuilding.gui.buildmode.RadialMenu;
|
|
||||||
import nl.requios.effortlessbuilding.helper.ReachHelper;
|
|
||||||
import nl.requios.effortlessbuilding.network.ModeActionMessage;
|
|
||||||
import nl.requios.effortlessbuilding.network.ModeSettingsMessage;
|
|
||||||
import nl.requios.effortlessbuilding.network.PacketHandler;
|
|
||||||
import nl.requios.effortlessbuilding.proxy.ClientProxy;
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* Main render class for Effortless Building
|
* Main render class for Effortless Building
|
||||||
@@ -70,90 +56,6 @@ public class RenderHandler {
|
|||||||
matrixStack.popPose();
|
matrixStack.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
//Display Radial Menu
|
|
||||||
public static void onRenderGameOverlay(final RenderGameOverlayEvent.Post event) {
|
|
||||||
Minecraft mc = Minecraft.getInstance();
|
|
||||||
ClientPlayerEntity player = mc.player;
|
|
||||||
|
|
||||||
//check if chisel and bits tool in hand (and has menu)
|
|
||||||
// final boolean hasChiselInHand = CompatHelper.chiselsAndBitsProxy.isHoldingChiselTool(EnumHand.MAIN_HAND);
|
|
||||||
|
|
||||||
final RenderGameOverlayEvent.ElementType type = event.getType();
|
|
||||||
//TODO 1.13 compatibility
|
|
||||||
if (type == RenderGameOverlayEvent.ElementType.ALL /*&& !hasChiselInHand*/) {
|
|
||||||
final boolean wasVisible = RadialMenu.instance.isVisible();
|
|
||||||
|
|
||||||
if (ClientProxy.keyBindings[3].isDown()) {
|
|
||||||
if (ReachHelper.getMaxReach(player) > 0) {
|
|
||||||
RadialMenu.instance.actionUsed = false;
|
|
||||||
RadialMenu.instance.raiseVisibility();
|
|
||||||
} else if (ClientProxy.keyBindings[3].consumeClick()) {
|
|
||||||
EffortlessBuilding.log(player, "Build modes are disabled until your reach has increased. Increase your reach with craftable reach upgrades.");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!RadialMenu.instance.actionUsed) {
|
|
||||||
ModeSettingsManager.ModeSettings modeSettings = ModeSettingsManager.getModeSettings(player);
|
|
||||||
|
|
||||||
if (RadialMenu.instance.switchTo != null) {
|
|
||||||
playRadialMenuSound();
|
|
||||||
modeSettings.setBuildMode(RadialMenu.instance.switchTo);
|
|
||||||
ModeSettingsManager.setModeSettings(player, modeSettings);
|
|
||||||
PacketHandler.INSTANCE.sendToServer(new ModeSettingsMessage(modeSettings));
|
|
||||||
|
|
||||||
EffortlessBuilding.log(player, I18n.get(modeSettings.getBuildMode().name), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Perform button action
|
|
||||||
ModeOptions.ActionEnum action = RadialMenu.instance.doAction;
|
|
||||||
if (action != null) {
|
|
||||||
ModeOptions.performAction(player, action);
|
|
||||||
PacketHandler.INSTANCE.sendToServer(new ModeActionMessage(action));
|
|
||||||
}
|
|
||||||
|
|
||||||
playRadialMenuSound();
|
|
||||||
}
|
|
||||||
|
|
||||||
RadialMenu.instance.actionUsed = true;
|
|
||||||
RadialMenu.instance.decreaseVisibility();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (RadialMenu.instance.isVisible()) {
|
|
||||||
|
|
||||||
int scaledWidth = mc.getWindow().getGuiScaledWidth();
|
|
||||||
int scaledHeight = mc.getWindow().getGuiScaledHeight();
|
|
||||||
RadialMenu.instance.configure(scaledWidth, scaledHeight);
|
|
||||||
|
|
||||||
if (!wasVisible) {
|
|
||||||
mc.mouseHandler.releaseMouse();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mc.mouseHandler.isMouseGrabbed()) {
|
|
||||||
KeyBinding.releaseAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
final int mouseX = ((int) mc.mouseHandler.xpos()) * scaledWidth / mc.getWindow().getWidth();
|
|
||||||
final int mouseY = scaledHeight - ((int) mc.mouseHandler.ypos()) * scaledHeight / mc.getWindow().getHeight() - 1;
|
|
||||||
|
|
||||||
net.minecraftforge.client.ForgeHooksClient.drawScreen(RadialMenu.instance, event.getMatrixStack(), mouseX, mouseY, event.getPartialTicks());
|
|
||||||
} else {
|
|
||||||
if (wasVisible &&
|
|
||||||
RadialMenu.instance.doAction != ModeOptions.ActionEnum.OPEN_MODIFIER_SETTINGS &&
|
|
||||||
RadialMenu.instance.doAction != ModeOptions.ActionEnum.OPEN_PLAYER_SETTINGS) {
|
|
||||||
mc.mouseHandler.grabMouse();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void playRadialMenuSound() {
|
|
||||||
final float volume = 0.1f;
|
|
||||||
if (volume >= 0.0001f) {
|
|
||||||
SimpleSound sound = new SimpleSound(SoundEvents.UI_BUTTON_CLICK, SoundCategory.MASTER, volume, 1.0f, Minecraft.getInstance().player.blockPosition());
|
|
||||||
Minecraft.getInstance().getSoundManager().play(sound);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static IVertexBuilder beginLines(IRenderTypeBuffer.Impl renderTypeBuffer) {
|
protected static IVertexBuilder beginLines(IRenderTypeBuffer.Impl renderTypeBuffer) {
|
||||||
return renderTypeBuffer.getBuffer(BuildRenderTypes.LINES);
|
return renderTypeBuffer.getBuffer(BuildRenderTypes.LINES);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,3 @@
|
|||||||
# This is an example mods.toml file. It contains the data relating to the loading mods.
|
|
||||||
# There are several mandatory fields (#mandatory), and many more that are optional (#optional).
|
|
||||||
# The overall format is standard TOML format, v0.5.0.
|
|
||||||
# Note that there are a couple of TOML lists in this file.
|
|
||||||
# Find more information on toml format here: https://github.com/toml-lang/toml
|
|
||||||
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
|
|
||||||
modLoader="javafml" #mandatory
|
modLoader="javafml" #mandatory
|
||||||
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
|
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
|
||||||
loaderVersion="[34,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
|
loaderVersion="[34,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
|
||||||
@@ -30,7 +24,7 @@ credits="" #optional
|
|||||||
authors="Requios" #optional
|
authors="Requios" #optional
|
||||||
# The description text for the mod (multi line!) (#mandatory)
|
# The description text for the mod (multi line!) (#mandatory)
|
||||||
description='''
|
description='''
|
||||||
Makes building easier by providing tools like mirrors, arrays, QuickReplace and a block randomizer. For survival and creative mode.
|
Makes building easier by providing tools like mirrors, arrays, build modes and a block randomizer. For survival and creative mode.
|
||||||
'''
|
'''
|
||||||
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
|
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
|
||||||
[[dependencies.examplemod]] #optional
|
[[dependencies.examplemod]] #optional
|
||||||
|
|||||||
@@ -1,25 +1,25 @@
|
|||||||
{
|
{
|
||||||
"effortlessbuilding.screen.modifier_settings": "Modifier Settings",
|
"effortlessbuilding.screen.modifier_settings": "Modifier Settings",
|
||||||
"effortlessbuilding.screen.radial_menu": "Build Modes",
|
"effortlessbuilding.screen.radial_menu": "Build Modes",
|
||||||
"effortlessbuilding.screen.randomizer_bag": "Randomizer Bag",
|
|
||||||
"effortlessbuilding.screen.player_settings": "Player Settings",
|
"effortlessbuilding.screen.player_settings": "Player Settings",
|
||||||
|
|
||||||
"key.effortlessbuilding.category": "Effortless Building",
|
"key.effortlessbuilding.category": "Effortless Building",
|
||||||
"key.effortlessbuilding.hud.desc": "Modifier Menu",
|
"key.effortlessbuilding.hud.desc": "Modifier Menu",
|
||||||
"key.effortlessbuilding.replace.desc": "Toggle QuickReplace",
|
"key.effortlessbuilding.replace.desc": "Toggle QuickReplace",
|
||||||
"key.effortlessbuilding.creative.desc": "Toggle Survival/Creative Mode",
|
|
||||||
"key.effortlessbuilding.mode.desc": "Radial Menu",
|
"key.effortlessbuilding.mode.desc": "Radial Menu",
|
||||||
"key.effortlessbuilding.undo.desc": "Undo",
|
"key.effortlessbuilding.undo.desc": "Undo",
|
||||||
"key.effortlessbuilding.redo.desc": "Redo",
|
"key.effortlessbuilding.redo.desc": "Redo",
|
||||||
"key.effortlessbuilding.altplacement.desc": "Alternative placement",
|
"key.effortlessbuilding.altplacement.desc": "Alternative placement",
|
||||||
|
|
||||||
"effortlessbuilding:randomizer_bag": "Randomizer Bag",
|
"effortlessbuilding:randomizer_bag": "Leather Randomizer Bag",
|
||||||
|
"effortlessbuilding:golden_randomizer_bag": "Golden Randomizer Bag",
|
||||||
|
"effortlessbuilding:diamond_randomizer_bag": "Diamond Randomizer Bag",
|
||||||
"effortlessbuilding:reach_upgrade1": "Reach Upgrade 1",
|
"effortlessbuilding:reach_upgrade1": "Reach Upgrade 1",
|
||||||
"effortlessbuilding:reach_upgrade2": "Reach Upgrade 2",
|
"effortlessbuilding:reach_upgrade2": "Reach Upgrade 2",
|
||||||
"effortlessbuilding:reach_upgrade3": "Reach Upgrade 3",
|
"effortlessbuilding:reach_upgrade3": "Reach Upgrade 3",
|
||||||
|
|
||||||
"effortlessbuilding.mode.normal": "Normal",
|
"effortlessbuilding.mode.normal": "Disable",
|
||||||
"effortlessbuilding.mode.normal_plus": "Normal+",
|
"effortlessbuilding.mode.normal_plus": "Single",
|
||||||
"effortlessbuilding.mode.line": "Line",
|
"effortlessbuilding.mode.line": "Line",
|
||||||
"effortlessbuilding.mode.wall": "Wall",
|
"effortlessbuilding.mode.wall": "Wall",
|
||||||
"effortlessbuilding.mode.floor": "Floor",
|
"effortlessbuilding.mode.floor": "Floor",
|
||||||
@@ -30,6 +30,25 @@
|
|||||||
"effortlessbuilding.mode.circle": "Circle",
|
"effortlessbuilding.mode.circle": "Circle",
|
||||||
"effortlessbuilding.mode.cylinder": "Cylinder",
|
"effortlessbuilding.mode.cylinder": "Cylinder",
|
||||||
"effortlessbuilding.mode.sphere": "Sphere",
|
"effortlessbuilding.mode.sphere": "Sphere",
|
||||||
|
"effortlessbuilding.mode.pyramid": "Pyramid",
|
||||||
|
"effortlessbuilding.mode.cone": "Cone",
|
||||||
|
"effortlessbuilding.mode.dome": "Dome",
|
||||||
|
|
||||||
|
"effortlessbuilding.modedescription.normal": "Disable mod and use vanilla placement rules",
|
||||||
|
"effortlessbuilding.modedescription.normal_plus": "Like vanilla, but with increased reach and placement preview",
|
||||||
|
"effortlessbuilding.modedescription.line": "",
|
||||||
|
"effortlessbuilding.modedescription.wall": "",
|
||||||
|
"effortlessbuilding.modedescription.floor": "",
|
||||||
|
"effortlessbuilding.modedescription.diagonal_line": "",
|
||||||
|
"effortlessbuilding.modedescription.diagonal_wall": "",
|
||||||
|
"effortlessbuilding.modedescription.slope_floor": "",
|
||||||
|
"effortlessbuilding.modedescription.cube": "",
|
||||||
|
"effortlessbuilding.modedescription.circle": "",
|
||||||
|
"effortlessbuilding.modedescription.cylinder": "",
|
||||||
|
"effortlessbuilding.modedescription.sphere": "",
|
||||||
|
"effortlessbuilding.modedescription.pyramid": "",
|
||||||
|
"effortlessbuilding.modedescription.cone": "",
|
||||||
|
"effortlessbuilding.modedescription.dome": "",
|
||||||
|
|
||||||
"effortlessbuilding.action.undo": "Undo",
|
"effortlessbuilding.action.undo": "Undo",
|
||||||
"effortlessbuilding.action.redo": "Redo",
|
"effortlessbuilding.action.redo": "Redo",
|
||||||
|
|||||||
79
src/main/resources/assets/effortlessbuilding/lang/ru_ru.json
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
{
|
||||||
|
"efortlessbuilding.screen.modifier_settings": "Настройки модификатора",
|
||||||
|
"efortlessbuilding.screen.radial_menu": "Режимы строительства",
|
||||||
|
"efortlessbuilding.screen.player_settings": "Настройки игрока",
|
||||||
|
|
||||||
|
"key.efortlessbuilding.category": "Строительство без усилий",
|
||||||
|
"key.efortlessbuilding.hud.desc": "Меню модификаторов",
|
||||||
|
"key.effortlessbuilding.replace.desc": "Переключить быструю замену",
|
||||||
|
"key.efortlessbuilding.mode.desc": "Круговое меню",
|
||||||
|
"key.efortlessbuilding.undo.desc": "Отменить",
|
||||||
|
"key.effortlessbuilding.redo.desc": "Повторить",
|
||||||
|
"key.efortlessbuilding.altplacement.desc": "Альтернативное размещение",
|
||||||
|
|
||||||
|
"efortlessbuilding:randomizer_bag": "Кожаная сумка рандомизатора",
|
||||||
|
"efortlessbuilding:golden_randomizer_bag": "Золотой мешок рандомизатора",
|
||||||
|
"efortlessbuilding:diamond_randomizer_bag": "Бриллиантовый рандомизатор",
|
||||||
|
"efortlessbuilding:reach_upgrade1": "Достичь улучшения 1",
|
||||||
|
"efortlessbuilding:reach_upgrade2": "Достичь улучшения 2",
|
||||||
|
"efortlessbuilding:reach_upgrade3": "Достичь улучшения 3",
|
||||||
|
|
||||||
|
"efortlessbuilding.mode.normal": "Отключить",
|
||||||
|
"efortlessbuilding.mode.normal_plus": "Одиночный",
|
||||||
|
"efortlessbuilding.mode.line": "Линия",
|
||||||
|
"efortlessbuilding.mode.wall": "Стена",
|
||||||
|
"efortlessbuilding.mode.floor": "Этаж",
|
||||||
|
"efortlessbuilding.mode.diagonal_line": "Диагональная линия",
|
||||||
|
"efortlessbuilding.mode.diagonal_wall": "Диагональная стена",
|
||||||
|
"effortlessbuilding.mode.slope_floor": "Наклонный этаж",
|
||||||
|
"effortlessbuilding.mode.cube": "Куб",
|
||||||
|
"efortlessbuilding.mode.circle": "Круг",
|
||||||
|
"efortlessbuilding.mode.cylinder": "Цилиндр",
|
||||||
|
"efortlessbuilding.mode.sphere": "Сфера",
|
||||||
|
"efortlessbuilding.mode.pyramid": "Пирамида",
|
||||||
|
"effortlessbuilding.mode.cone": "Конус",
|
||||||
|
"efortlessbuilding.mode.dome": "Купол",
|
||||||
|
|
||||||
|
"effortlessbuilding.modedescription.normal": "Отключить мод и использовать ванильные правила размещения",
|
||||||
|
"effortlessbuilding.modedescription.normal_plus": "Как и ваниль, но с увеличенным охватом и предварительным просмотром места размещения",
|
||||||
|
"efortlessbuilding.modedescription.line": "",
|
||||||
|
"efortlessbuilding.modedescription.wall": "",
|
||||||
|
"efortlessbuilding.modedescription.floor": "",
|
||||||
|
"efortlessbuilding.modedescription.diagonal_line": "",
|
||||||
|
"efortlessbuilding.modedescription.diagonal_wall": "",
|
||||||
|
"effortlessbuilding.modedescription.slope_floor": "",
|
||||||
|
"efortlessbuilding.modedescription.cube": "",
|
||||||
|
"efortlessbuilding.modedescription.circle": "",
|
||||||
|
"efortlessbuilding.modedescription.cylinder": "",
|
||||||
|
"efortlessbuilding.modedescription.sphere": "",
|
||||||
|
"efortlessbuilding.modedescription.pyramid": "",
|
||||||
|
"efortlessbuilding.modedescription.cone": "",
|
||||||
|
"efortlessbuilding.modedescription.dome": "",
|
||||||
|
|
||||||
|
"efortlessbuilding.action.undo": "Отменить",
|
||||||
|
"efortlessbuilding.action.redo": "Повторить",
|
||||||
|
"efortlessbuilding.action.replace": "Заменить",
|
||||||
|
"efortlessbuilding.action.open_modifier_settings": "Открыть настройки модификатора",
|
||||||
|
"efortlessbuilding.action.open_player_settings": "Открыть настройки",
|
||||||
|
|
||||||
|
"efortlessbuilding.action.build_speed": "Скорость сборки",
|
||||||
|
"efortlessbuilding.action.filling": "Заполнение",
|
||||||
|
"efortlessbuilding.action.raised_edge": "Приподнятый край",
|
||||||
|
"efortlessbuilding.action.thickness": "Толщина линии",
|
||||||
|
"efortlessbuilding.action.circle_start": "Начальная точка",
|
||||||
|
|
||||||
|
"efortlessbuilding.action.normal_speed": "Нормальный",
|
||||||
|
"efortlessbuilding.action.fast_speed": "Быстро",
|
||||||
|
"efortlessbuilding.action.full": "Заполнено",
|
||||||
|
"efortlessbuilding.action.hollow": "Пустой",
|
||||||
|
"efortlessbuilding.action.skeleton": "Скелет",
|
||||||
|
"efortlessbuilding.action.short_edge": "Короткая кромка",
|
||||||
|
"efortlessbuilding.action.long_edge": "Длинный край",
|
||||||
|
"efortlessbuilding.action.thickness_1": "Толщиной 1 блок",
|
||||||
|
"efortlessbuilding.action.thickness_3": "Толщиной 3 блока",
|
||||||
|
"efortlessbuilding.action.thickness_5": "Толщиной 5 блоков",
|
||||||
|
"efortlessbuilding.action.start_center": "Посередине",
|
||||||
|
"efortlessbuilding.action.start_corner": "Угол",
|
||||||
|
|
||||||
|
"commands.reach.usage": "/reach <уровень>"
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "effortlessbuilding:items/diamondrandomizerbag"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "effortlessbuilding:items/goldenrandomizerbag"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 920 B |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 361 B |
|
Before Width: | Height: | Size: 319 B After Width: | Height: | Size: 4.9 KiB |
|
After Width: | Height: | Size: 361 B |
|
Before Width: | Height: | Size: 317 B After Width: | Height: | Size: 333 B |
|
Before Width: | Height: | Size: 355 B After Width: | Height: | Size: 317 B |
|
After Width: | Height: | Size: 361 B |
|
After Width: | Height: | Size: 6.0 KiB |
|
After Width: | Height: | Size: 5.8 KiB |
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"type": "minecraft:crafting_shaped",
|
||||||
|
"pattern": [
|
||||||
|
"x#x",
|
||||||
|
"#O#",
|
||||||
|
"x#x"
|
||||||
|
],
|
||||||
|
"key": {
|
||||||
|
"O": {
|
||||||
|
"item": "minecraft:leather"
|
||||||
|
},
|
||||||
|
"#": {
|
||||||
|
"item": "minecraft:diamond"
|
||||||
|
},
|
||||||
|
"x": {
|
||||||
|
"item": "minecraft:purple_dye"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"result": {
|
||||||
|
"item": "effortlessbuilding:diamond_randomizer_bag"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"type": "minecraft:crafting_shaped",
|
||||||
|
"pattern": [
|
||||||
|
"x#x",
|
||||||
|
"#O#",
|
||||||
|
"x#x"
|
||||||
|
],
|
||||||
|
"key": {
|
||||||
|
"O": {
|
||||||
|
"item": "minecraft:leather"
|
||||||
|
},
|
||||||
|
"#": {
|
||||||
|
"item": "minecraft:gold_ingot"
|
||||||
|
},
|
||||||
|
"x": {
|
||||||
|
"item": "minecraft:quartz"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"result": {
|
||||||
|
"item": "effortlessbuilding:golden_randomizer_bag"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,15 +1,16 @@
|
|||||||
{
|
{
|
||||||
"type": "minecraft:crafting_shaped",
|
"type": "minecraft:crafting_shaped",
|
||||||
"pattern": [
|
"pattern": [
|
||||||
" S",
|
" # ",
|
||||||
"/ "
|
"#O#",
|
||||||
|
" # "
|
||||||
],
|
],
|
||||||
"key": {
|
"key": {
|
||||||
"S": {
|
"O": {
|
||||||
"item": "minecraft:string"
|
"item": "minecraft:ender_pearl"
|
||||||
},
|
},
|
||||||
"/": {
|
"#": {
|
||||||
"item": "minecraft:stick"
|
"item": "minecraft:slime_ball"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"result": {
|
"result": {
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
{
|
{
|
||||||
"type": "minecraft:crafting_shaped",
|
"type": "minecraft:crafting_shaped",
|
||||||
"pattern": [
|
"pattern": [
|
||||||
" M",
|
" # ",
|
||||||
"/ "
|
"#O#",
|
||||||
|
" # "
|
||||||
],
|
],
|
||||||
"key": {
|
"key": {
|
||||||
"M": {
|
"O": {
|
||||||
"item": "minecraft:magma_cream"
|
"item": "minecraft:ender_pearl"
|
||||||
},
|
},
|
||||||
"/": {
|
"#": {
|
||||||
"item": "minecraft:bone"
|
"item": "minecraft:blaze_powder"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"result": {
|
"result": {
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
{
|
{
|
||||||
"type": "minecraft:crafting_shaped",
|
"type": "minecraft:crafting_shaped",
|
||||||
"pattern": [
|
"pattern": [
|
||||||
" FE",
|
"x#x",
|
||||||
" /F",
|
"#O#",
|
||||||
"/ "
|
"x#x"
|
||||||
],
|
],
|
||||||
"key": {
|
"key": {
|
||||||
"E": {
|
"O": {
|
||||||
"item": "minecraft:ender_eye"
|
"item": "minecraft:end_crystal"
|
||||||
},
|
},
|
||||||
"F": {
|
"#": {
|
||||||
"item": "minecraft:feather"
|
"item": "minecraft:chorus_fruit"
|
||||||
},
|
},
|
||||||
"/": {
|
"x": {
|
||||||
"item": "minecraft:blaze_rod"
|
"item": "minecraft:ghast_tear"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"result": {
|
"result": {
|
||||||
|
|||||||