Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
74d74390d2 | ||
|
|
f764fac778 | ||
|
|
42661f884c | ||
|
|
df27697ecb | ||
|
|
fb622bcf99 | ||
|
|
4e3b1ef2ce | ||
|
|
83b23fe763 | ||
|
|
ac429ca64e |
26
build.gradle
26
build.gradle
@@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle'
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'maven-publish'
|
||||
|
||||
version = '1.13.2-2.16'
|
||||
version = '1.14.4-2.18'
|
||||
group = 'nl.requios.effortlessbuilding' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = 'effortlessbuilding'
|
||||
|
||||
@@ -25,10 +25,10 @@ minecraft {
|
||||
// stable_# Stables are built at the discretion of the MCP team.
|
||||
// Use non-default mappings at your own risk. they may not always work.
|
||||
// Simply re-run your setup task after changing the mappings to update your workspace.
|
||||
mappings channel: 'snapshot', version: '20180921-1.13'
|
||||
mappings channel: 'snapshot', version: '20190719-1.14.3'
|
||||
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
|
||||
|
||||
// accessTransformer = file('build/resources/main/META-INF/accesstransformer.cfg')
|
||||
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||
|
||||
// Default run configurations.
|
||||
// These can be tweaked, removed, or duplicated as needed.
|
||||
@@ -64,6 +64,24 @@ minecraft {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data {
|
||||
workingDirectory project.file('run')
|
||||
|
||||
// Recommended logging data for a userdev environment (SCAN,REGISTRIES,REGISTRYDUMP)
|
||||
property 'forge.logging.markers', 'REGISTRIES'
|
||||
|
||||
// Recommended logging level for the console
|
||||
property 'forge.logging.console.level', 'debug'
|
||||
|
||||
args '--mod', 'effortlessbuilding', '--all', '--output', file('src/generated/resources/')
|
||||
|
||||
mods {
|
||||
effortlessbuilding {
|
||||
source sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +89,7 @@ dependencies {
|
||||
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
|
||||
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
|
||||
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
|
||||
minecraft 'net.minecraftforge:forge:1.13.2-25.0.219'
|
||||
minecraft 'net.minecraftforge:forge:1.14.4-28.1.102'
|
||||
|
||||
// You may put jars on which you depend on in ./libs or you may define them like so..
|
||||
// compile "some.group:artifact:version:classifier"
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
package nl.requios.effortlessbuilding;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||
import net.minecraftforge.common.crafting.CraftingHelper;
|
||||
@@ -20,13 +23,11 @@ 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.network.NetworkRegistry;
|
||||
import nl.requios.effortlessbuilding.capability.ModeCapabilityManager;
|
||||
import nl.requios.effortlessbuilding.capability.ModifierCapabilityManager;
|
||||
import nl.requios.effortlessbuilding.command.CommandReach;
|
||||
import nl.requios.effortlessbuilding.compatibility.CompatHelper;
|
||||
import nl.requios.effortlessbuilding.gui.RandomizerBagGuiHandler;
|
||||
import nl.requios.effortlessbuilding.helper.ReachConditionFactory;
|
||||
import nl.requios.effortlessbuilding.gui.RandomizerBagContainer;
|
||||
import nl.requios.effortlessbuilding.item.ItemRandomizerBag;
|
||||
import nl.requios.effortlessbuilding.item.ItemReachUpgrade1;
|
||||
import nl.requios.effortlessbuilding.item.ItemReachUpgrade2;
|
||||
@@ -35,7 +36,6 @@ import nl.requios.effortlessbuilding.network.PacketHandler;
|
||||
import nl.requios.effortlessbuilding.proxy.ClientProxy;
|
||||
import nl.requios.effortlessbuilding.proxy.IProxy;
|
||||
import nl.requios.effortlessbuilding.proxy.ServerProxy;
|
||||
import nl.requios.effortlessbuilding.render.ShaderHandler;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -46,7 +46,7 @@ public class EffortlessBuilding
|
||||
{
|
||||
public static final String MODID = "effortlessbuilding";
|
||||
public static final String NAME = "Effortless Building";
|
||||
public static final String VERSION = "1.13.2-2.16";
|
||||
public static final String VERSION = "1.14.4-2.18";
|
||||
|
||||
public static EffortlessBuilding instance;
|
||||
|
||||
@@ -69,6 +69,7 @@ public class EffortlessBuilding
|
||||
ITEM_REACH_UPGRADE_3
|
||||
};
|
||||
|
||||
public static final ContainerType<RandomizerBagContainer> RANDOMIZER_BAG_CONTAINER = register("randomizer_bag", RandomizerBagContainer::new);
|
||||
public static final ResourceLocation RANDOMIZER_BAG_GUI = new ResourceLocation(EffortlessBuilding.MODID, "randomizer_bag");
|
||||
|
||||
public EffortlessBuilding() {
|
||||
@@ -98,14 +99,9 @@ public class EffortlessBuilding
|
||||
|
||||
PacketHandler.register();
|
||||
|
||||
//Register recipe condition
|
||||
CraftingHelper.register(new ResourceLocation(MODID, "enable_reach_upgrades"), new ReachConditionFactory());
|
||||
|
||||
//TODO 1.13 config
|
||||
// ConfigManager.sync(MODID, Config.Type.INSTANCE);
|
||||
|
||||
ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.GUIFACTORY, () -> RandomizerBagGuiHandler::openGui);
|
||||
|
||||
proxy.setup(event);
|
||||
|
||||
CompatHelper.setup();
|
||||
@@ -138,16 +134,24 @@ public class EffortlessBuilding
|
||||
CommandReach.register(event.getCommandDispatcher());
|
||||
}
|
||||
|
||||
private static <T extends Container> ContainerType<T> register(String key, ContainerType.IFactory<T> factory) {
|
||||
return Registry.register(Registry.MENU, key, new ContainerType<>(factory));
|
||||
}
|
||||
|
||||
public static void log(String msg){
|
||||
logger.info(msg);
|
||||
}
|
||||
|
||||
public static void log(EntityPlayer player, String msg){
|
||||
public static void log(PlayerEntity player, String msg){
|
||||
log(player, msg, false);
|
||||
}
|
||||
|
||||
public static void log(EntityPlayer player, String msg, boolean actionBar){
|
||||
player.sendStatusMessage(new TextComponentString(msg), actionBar);
|
||||
public static void log(PlayerEntity player, String msg, boolean actionBar){
|
||||
player.sendStatusMessage(new StringTextComponent(msg), actionBar);
|
||||
}
|
||||
|
||||
//Log with translation supported, call either on client or server (which then sends a message)
|
||||
public static void logTranslate(PlayerEntity player, String prefix, String translationKey, String suffix, boolean actionBar){
|
||||
proxy.logTranslate(player, prefix, translationKey, suffix, actionBar);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
package nl.requios.effortlessbuilding;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.stats.Stat;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.event.AttachCapabilitiesEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
@@ -33,15 +31,13 @@ import nl.requios.effortlessbuilding.network.RequestLookAtMessage;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static net.minecraftforge.fml.common.gameevent.PlayerEvent.*;
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
public class EventHandler
|
||||
{
|
||||
|
||||
@SubscribeEvent
|
||||
public static void attachCapabilities(AttachCapabilitiesEvent<Entity> event) {
|
||||
if (event.getObject() instanceof EntityPlayer) {
|
||||
if (event.getObject() instanceof PlayerEntity) {
|
||||
event.addCapability(new ResourceLocation(EffortlessBuilding.MODID, "build_modifier"), new ModifierCapabilityManager.Provider());
|
||||
event.addCapability(new ResourceLocation(EffortlessBuilding.MODID, "build_mode"), new ModeCapabilityManager.Provider());
|
||||
}
|
||||
@@ -67,10 +63,10 @@ public class EventHandler
|
||||
public static void onBlockPlaced(BlockEvent.EntityPlaceEvent event) {
|
||||
if (event.getWorld().isRemote()) return;
|
||||
|
||||
if (!(event.getEntity() instanceof EntityPlayer)) return;
|
||||
if (!(event.getEntity() instanceof PlayerEntity)) return;
|
||||
|
||||
//Cancel event if necessary
|
||||
EntityPlayerMP player = ((EntityPlayerMP) event.getEntity());
|
||||
ServerPlayerEntity player = ((ServerPlayerEntity) event.getEntity());
|
||||
BuildModes.BuildModeEnum buildMode = ModeSettingsManager.getModeSettings(player).getBuildMode();
|
||||
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
|
||||
|
||||
@@ -112,7 +108,7 @@ public class EventHandler
|
||||
BuildModes.onBlockBroken(event.getPlayer(), event.getPos(), false);
|
||||
|
||||
//Add to undo stack in client
|
||||
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (EntityPlayerMP) event.getPlayer()), new AddUndoMessage(event.getPos(), event.getState(), Blocks.AIR.getDefaultState()));
|
||||
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) event.getPlayer()), new AddUndoMessage(event.getPos(), event.getState(), Blocks.AIR.getDefaultState()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +117,7 @@ public class EventHandler
|
||||
//Disable if config says so
|
||||
if (!BuildConfig.survivalBalancers.increasedMiningTime.get()) return;
|
||||
|
||||
EntityPlayer player = event.getEntityPlayer();
|
||||
PlayerEntity player = event.getEntityPlayer();
|
||||
World world = player.world;
|
||||
BlockPos pos = event.getPos();
|
||||
|
||||
@@ -135,7 +131,7 @@ public class EventHandler
|
||||
for (int i = 1; i < coordinates.size(); i++) {
|
||||
BlockPos coordinate = coordinates.get(i);
|
||||
//get existing blockstates at those coordinates
|
||||
IBlockState blockState = world.getBlockState(coordinate);
|
||||
BlockState blockState = world.getBlockState(coordinate);
|
||||
//add hardness for each blockstate, if can break
|
||||
if (SurvivalHelper.canBreak(world, player, coordinate))
|
||||
totalBlockHardness += blockState.getBlockHardness(world, coordinate);
|
||||
@@ -154,31 +150,31 @@ public class EventHandler
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onPlayerLoggedIn(PlayerLoggedInEvent event) {
|
||||
EntityPlayer player = event.getPlayer();
|
||||
public static void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
|
||||
PlayerEntity player = event.getPlayer();
|
||||
ModifierSettingsManager.handleNewPlayer(player);
|
||||
ModeSettingsManager.handleNewPlayer(player);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onPlayerLoggedOut(PlayerLoggedOutEvent event) {
|
||||
EntityPlayer player = event.getPlayer();
|
||||
public static void onPlayerLoggedOut(PlayerEvent.PlayerLoggedOutEvent event) {
|
||||
PlayerEntity player = event.getPlayer();
|
||||
if (player.getEntityWorld().isRemote) return;
|
||||
|
||||
UndoRedo.clear(player);
|
||||
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (EntityPlayerMP) player), new ClearUndoMessage());
|
||||
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), new ClearUndoMessage());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||
EntityPlayer player = event.getPlayer();
|
||||
public static void onPlayerRespawn(PlayerEvent.PlayerRespawnEvent event) {
|
||||
PlayerEntity player = event.getPlayer();
|
||||
ModifierSettingsManager.handleNewPlayer(player);
|
||||
ModeSettingsManager.handleNewPlayer(player);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onPlayerChangedDimension(PlayerChangedDimensionEvent event) {
|
||||
EntityPlayer player = event.getPlayer();
|
||||
public static void onPlayerChangedDimension(PlayerEvent.PlayerChangedDimensionEvent event) {
|
||||
PlayerEntity player = event.getPlayer();
|
||||
if (player.getEntityWorld().isRemote) return;
|
||||
|
||||
//Set build mode to normal
|
||||
@@ -197,16 +193,16 @@ public class EventHandler
|
||||
ModeSettingsManager.handleNewPlayer(player);
|
||||
|
||||
UndoRedo.clear(player);
|
||||
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (EntityPlayerMP) player), new ClearUndoMessage());
|
||||
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), new ClearUndoMessage());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onPlayerClone(PlayerEvent.Clone event) {
|
||||
//Attach capabilities on death, otherwise crash
|
||||
EntityPlayer oldPlayer = event.getOriginal();
|
||||
PlayerEntity oldPlayer = event.getOriginal();
|
||||
oldPlayer.revive();
|
||||
|
||||
EntityPlayer newPlayer = event.getEntityPlayer();
|
||||
PlayerEntity newPlayer = event.getEntityPlayer();
|
||||
ModifierSettingsManager.setModifierSettings(newPlayer, ModifierSettingsManager.getModifierSettings(oldPlayer));
|
||||
ModeSettingsManager.setModeSettings(newPlayer, ModeSettingsManager.getModeSettings(oldPlayer));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package nl.requios.effortlessbuilding;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
||||
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD, value = {Dist.CLIENT})
|
||||
public class ModClientEventHandler {
|
||||
|
||||
private static final HashMap<BuildModes.BuildModeEnum, ResourceLocation> buildModeIcons = new HashMap<>();
|
||||
private static final HashMap<ModeOptions.ActionEnum, ResourceLocation> modeOptionIcons = new HashMap<>();
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onTextureStitch(final TextureStitchEvent.Pre event) {
|
||||
//register icon textures
|
||||
for (final BuildModes.BuildModeEnum mode : BuildModes.BuildModeEnum.values())
|
||||
{
|
||||
final ResourceLocation spriteLocation = new ResourceLocation(EffortlessBuilding.MODID, "icons/" + mode.name().toLowerCase());
|
||||
event.addSprite(spriteLocation);
|
||||
buildModeIcons.put(mode, spriteLocation);
|
||||
}
|
||||
|
||||
for (final ModeOptions.ActionEnum action : ModeOptions.ActionEnum.values())
|
||||
{
|
||||
final ResourceLocation spriteLocation = new ResourceLocation(EffortlessBuilding.MODID, "icons/" + action.name().toLowerCase());
|
||||
event.addSprite(spriteLocation);
|
||||
modeOptionIcons.put(action, spriteLocation);
|
||||
}
|
||||
}
|
||||
|
||||
public static TextureAtlasSprite getBuildModeIcon(BuildModes.BuildModeEnum mode) {
|
||||
return Minecraft.getInstance().getTextureMap().getSprite(buildModeIcons.get(mode));
|
||||
}
|
||||
|
||||
public static TextureAtlasSprite getModeOptionIcon(ModeOptions.ActionEnum action) {
|
||||
return Minecraft.getInstance().getTextureMap().getSprite(modeOptionIcons.get(action));
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,20 @@
|
||||
package nl.requios.effortlessbuilding;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
||||
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
// You can use EventBusSubscriber to automatically subscribe events on the contained class (this is subscribing to the MOD
|
||||
// Event bus for receiving Registry Events)
|
||||
@@ -18,13 +27,19 @@ public class ModEventHandler {
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerItems(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
public static void registerItems(RegistryEvent.Register<Item> event) {
|
||||
event.getRegistry().registerAll(EffortlessBuilding.ITEMS);
|
||||
|
||||
for (Block block : EffortlessBuilding.BLOCKS)
|
||||
{
|
||||
event.getRegistry().register(new ItemBlock(block, new Item.Properties()).setRegistryName(block.getRegistryName()));
|
||||
event.getRegistry().register(new BlockItem(block, new Item.Properties()).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
}
|
||||
|
||||
// @SubscribeEvent
|
||||
// public static void registerContainerTypes(RegistryEvent.Register<ContainerType<?>> event) {
|
||||
// event.getRegistry().register()
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package nl.requios.effortlessbuilding.buildmode;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import java.util.Dictionary;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class BaseBuildMode implements IBuildMode {
|
||||
@@ -16,25 +15,25 @@ public abstract class BaseBuildMode implements IBuildMode {
|
||||
protected Dictionary<UUID, Integer> rightClickClientTable = new Hashtable<>();
|
||||
protected Dictionary<UUID, Integer> rightClickServerTable = new Hashtable<>();
|
||||
protected Dictionary<UUID, BlockPos> firstPosTable = new Hashtable<>();
|
||||
protected Dictionary<UUID, EnumFacing> sideHitTable = new Hashtable<>();
|
||||
protected Dictionary<UUID, Direction> sideHitTable = new Hashtable<>();
|
||||
protected Dictionary<UUID, Vec3d> hitVecTable = new Hashtable<>();
|
||||
|
||||
@Override
|
||||
public void initialize(EntityPlayer player) {
|
||||
public void initialize(PlayerEntity player) {
|
||||
rightClickClientTable.put(player.getUniqueID(), 0);
|
||||
rightClickServerTable.put(player.getUniqueID(), 0);
|
||||
firstPosTable.put(player.getUniqueID(), BlockPos.ORIGIN);
|
||||
sideHitTable.put(player.getUniqueID(), EnumFacing.UP);
|
||||
firstPosTable.put(player.getUniqueID(), BlockPos.ZERO);
|
||||
sideHitTable.put(player.getUniqueID(), Direction.UP);
|
||||
hitVecTable.put(player.getUniqueID(), Vec3d.ZERO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getSideHit(EntityPlayer player) {
|
||||
public Direction getSideHit(PlayerEntity player) {
|
||||
return sideHitTable.get(player.getUniqueID());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getHitVec(EntityPlayer player) {
|
||||
public Vec3d getHitVec(PlayerEntity player) {
|
||||
return hitVecTable.get(player.getUniqueID());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package nl.requios.effortlessbuilding.buildmode;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceFluidMode;
|
||||
import net.minecraft.util.math.RayTraceContext;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
@@ -26,8 +26,8 @@ public class BuildModes {
|
||||
|
||||
//Static variables are shared between client and server in singleplayer
|
||||
//We need them separate
|
||||
public static Dictionary<EntityPlayer, Boolean> currentlyBreakingClient = new Hashtable<>();
|
||||
public static Dictionary<EntityPlayer, Boolean> currentlyBreakingServer = new Hashtable<>();
|
||||
public static Dictionary<PlayerEntity, Boolean> currentlyBreakingClient = new Hashtable<>();
|
||||
public static Dictionary<PlayerEntity, Boolean> currentlyBreakingServer = new Hashtable<>();
|
||||
|
||||
public enum BuildModeEnum {
|
||||
NORMAL("effortlessbuilding.mode.normal", new Normal()),
|
||||
@@ -57,10 +57,10 @@ public class BuildModes {
|
||||
//Uses a network message to get the previous raytraceresult from the player
|
||||
//The server could keep track of all raytraceresults but this might lag with many players
|
||||
//Raytraceresult is needed for sideHit and hitVec
|
||||
public static void onBlockPlacedMessage(EntityPlayer player, BlockPlacedMessage message) {
|
||||
public static void onBlockPlacedMessage(PlayerEntity player, BlockPlacedMessage message) {
|
||||
|
||||
//Check if not in the middle of breaking
|
||||
Dictionary<EntityPlayer, Boolean> currentlyBreaking = player.world.isRemote ? currentlyBreakingClient : currentlyBreakingServer;
|
||||
Dictionary<PlayerEntity, Boolean> currentlyBreaking = player.world.isRemote ? currentlyBreakingClient : currentlyBreakingServer;
|
||||
if (currentlyBreaking.get(player) != null && currentlyBreaking.get(player)) {
|
||||
//Cancel breaking
|
||||
initializeMode(player);
|
||||
@@ -112,7 +112,7 @@ public class BuildModes {
|
||||
coordinates = coordinates.subList(0, limit);
|
||||
}
|
||||
|
||||
EnumFacing sideHit = buildMode.instance.getSideHit(player);
|
||||
Direction sideHit = buildMode.instance.getSideHit(player);
|
||||
if (sideHit == null) sideHit = message.getSideHit();
|
||||
|
||||
Vec3d hitVec = buildMode.instance.getHitVec(player);
|
||||
@@ -127,15 +127,15 @@ public class BuildModes {
|
||||
}
|
||||
|
||||
//Use a network message to break blocks in the distance using clientside mouse input
|
||||
public static void onBlockBrokenMessage(EntityPlayer player, BlockBrokenMessage message) {
|
||||
public static void onBlockBrokenMessage(PlayerEntity player, BlockBrokenMessage message) {
|
||||
BlockPos startPos = message.isBlockHit() ? message.getBlockPos() : null;
|
||||
onBlockBroken(player, startPos, true);
|
||||
}
|
||||
|
||||
public static void onBlockBroken(EntityPlayer player, BlockPos startPos, boolean breakStartPos) {
|
||||
public static void onBlockBroken(PlayerEntity player, BlockPos startPos, boolean breakStartPos) {
|
||||
|
||||
//Check if not in the middle of placing
|
||||
Dictionary<EntityPlayer, Boolean> currentlyBreaking = player.world.isRemote ? currentlyBreakingClient : currentlyBreakingServer;
|
||||
Dictionary<PlayerEntity, Boolean> currentlyBreaking = player.world.isRemote ? currentlyBreakingClient : currentlyBreakingServer;
|
||||
if (currentlyBreaking.get(player) != null && !currentlyBreaking.get(player)) {
|
||||
//Cancel placing
|
||||
initializeMode(player);
|
||||
@@ -153,7 +153,7 @@ public class BuildModes {
|
||||
|
||||
//Get coordinates
|
||||
BuildModeEnum buildMode = modeSettings.getBuildMode();
|
||||
List<BlockPos> coordinates = buildMode.instance.onRightClick(player, startPos, EnumFacing.UP, Vec3d.ZERO, true);
|
||||
List<BlockPos> coordinates = buildMode.instance.onRightClick(player, startPos, Direction.UP, Vec3d.ZERO, true);
|
||||
|
||||
if (coordinates.isEmpty()) {
|
||||
currentlyBreaking.put(player, true);
|
||||
@@ -168,7 +168,7 @@ public class BuildModes {
|
||||
currentlyBreaking.remove(player);
|
||||
}
|
||||
|
||||
public static List<BlockPos> findCoordinates(EntityPlayer player, BlockPos startPos, boolean skipRaytrace) {
|
||||
public static List<BlockPos> findCoordinates(PlayerEntity player, BlockPos startPos, boolean skipRaytrace) {
|
||||
List<BlockPos> coordinates = new ArrayList<>();
|
||||
|
||||
ModeSettingsManager.ModeSettings modeSettings = ModeSettingsManager.getModeSettings(player);
|
||||
@@ -177,27 +177,27 @@ public class BuildModes {
|
||||
return coordinates;
|
||||
}
|
||||
|
||||
public static void initializeMode(EntityPlayer player) {
|
||||
public static void initializeMode(PlayerEntity player) {
|
||||
//Resetting mode, so not placing or breaking
|
||||
Dictionary<EntityPlayer, Boolean> currentlyBreaking = player.world.isRemote ? currentlyBreakingClient : currentlyBreakingServer;
|
||||
Dictionary<PlayerEntity, Boolean> currentlyBreaking = player.world.isRemote ? currentlyBreakingClient : currentlyBreakingServer;
|
||||
currentlyBreaking.remove(player);
|
||||
|
||||
ModeSettingsManager.getModeSettings(player).getBuildMode().instance.initialize(player);
|
||||
}
|
||||
|
||||
public static boolean isCurrentlyPlacing(EntityPlayer player) {
|
||||
Dictionary<EntityPlayer, Boolean> currentlyBreaking = player.world.isRemote ? currentlyBreakingClient : currentlyBreakingServer;
|
||||
public static boolean isCurrentlyPlacing(PlayerEntity player) {
|
||||
Dictionary<PlayerEntity, Boolean> currentlyBreaking = player.world.isRemote ? currentlyBreakingClient : currentlyBreakingServer;
|
||||
return currentlyBreaking.get(player) != null && !currentlyBreaking.get(player);
|
||||
}
|
||||
|
||||
public static boolean isCurrentlyBreaking(EntityPlayer player) {
|
||||
Dictionary<EntityPlayer, Boolean> currentlyBreaking = player.world.isRemote ? currentlyBreakingClient : currentlyBreakingServer;
|
||||
public static boolean isCurrentlyBreaking(PlayerEntity player) {
|
||||
Dictionary<PlayerEntity, Boolean> currentlyBreaking = player.world.isRemote ? currentlyBreakingClient : currentlyBreakingServer;
|
||||
return currentlyBreaking.get(player) != null && currentlyBreaking.get(player);
|
||||
}
|
||||
|
||||
//Either placing or breaking
|
||||
public static boolean isActive(EntityPlayer player) {
|
||||
Dictionary<EntityPlayer, Boolean> currentlyBreaking = player.world.isRemote ? currentlyBreakingClient : currentlyBreakingServer;
|
||||
public static boolean isActive(PlayerEntity player) {
|
||||
Dictionary<PlayerEntity, Boolean> currentlyBreaking = player.world.isRemote ? currentlyBreakingClient : currentlyBreakingServer;
|
||||
return currentlyBreaking.get(player) != null;
|
||||
}
|
||||
|
||||
@@ -229,13 +229,14 @@ public class BuildModes {
|
||||
return new Vec3d(x, y, z);
|
||||
}
|
||||
|
||||
public static boolean isCriteriaValid(Vec3d start, Vec3d look, int reach, EntityPlayer player, boolean skipRaytrace, Vec3d lineBound, Vec3d planeBound, double distToPlayerSq) {
|
||||
public static boolean isCriteriaValid(Vec3d start, Vec3d look, int reach, PlayerEntity player, boolean skipRaytrace, Vec3d lineBound, Vec3d planeBound, double distToPlayerSq) {
|
||||
boolean intersects = false;
|
||||
if (!skipRaytrace) {
|
||||
//collision within a 1 block radius to selected is fine
|
||||
RayTraceResult rayTraceResult = player.world.rayTraceBlocks(start, lineBound, RayTraceFluidMode.NEVER, true, false);
|
||||
intersects = rayTraceResult != null && rayTraceResult.type == RayTraceResult.Type.BLOCK &&
|
||||
planeBound.subtract(rayTraceResult.hitVec).lengthSquared() > 4;
|
||||
RayTraceContext rayTraceContext = new RayTraceContext(start, lineBound, RayTraceContext.BlockMode.COLLIDER, RayTraceContext.FluidMode.NONE, player);
|
||||
RayTraceResult rayTraceResult = player.world.rayTraceBlocks(rayTraceContext);
|
||||
intersects = rayTraceResult != null && rayTraceResult.getType() == RayTraceResult.Type.BLOCK &&
|
||||
planeBound.subtract(rayTraceResult.getHitVec()).lengthSquared() > 4;
|
||||
}
|
||||
|
||||
return planeBound.subtract(start).dotProduct(look) > 0 &&
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package nl.requios.effortlessbuilding.buildmode;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
@@ -10,16 +10,16 @@ import java.util.List;
|
||||
public interface IBuildMode {
|
||||
|
||||
//Fired when a player selects a buildmode and when it needs to initializeMode
|
||||
void initialize(EntityPlayer player);
|
||||
void initialize(PlayerEntity player);
|
||||
|
||||
//Fired when a block would be placed
|
||||
//Return a list of coordinates where you want to place blocks
|
||||
List<BlockPos> onRightClick(EntityPlayer player, BlockPos blockPos, EnumFacing sideHit, Vec3d hitVec, boolean skipRaytrace);
|
||||
List<BlockPos> onRightClick(PlayerEntity player, BlockPos blockPos, Direction sideHit, Vec3d hitVec, boolean skipRaytrace);
|
||||
|
||||
//Fired continuously for visualization purposes
|
||||
List<BlockPos> findCoordinates(EntityPlayer player, BlockPos blockPos, boolean skipRaytrace);
|
||||
List<BlockPos> findCoordinates(PlayerEntity player, BlockPos blockPos, boolean skipRaytrace);
|
||||
|
||||
EnumFacing getSideHit(EntityPlayer player);
|
||||
Direction getSideHit(PlayerEntity player);
|
||||
|
||||
Vec3d getHitVec(EntityPlayer player);
|
||||
Vec3d getHitVec(PlayerEntity player);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package nl.requios.effortlessbuilding.buildmode;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
|
||||
@@ -110,7 +110,7 @@ public class ModeOptions {
|
||||
}
|
||||
|
||||
//Called on both client and server
|
||||
public static void performAction(EntityPlayer player, ActionEnum action) {
|
||||
public static void performAction(PlayerEntity player, ActionEnum action) {
|
||||
if (action == null) return;
|
||||
|
||||
switch (action) {
|
||||
@@ -176,7 +176,7 @@ public class ModeOptions {
|
||||
}
|
||||
|
||||
if (player.world.isRemote && action != ActionEnum.REPLACE && action != ActionEnum.OPEN_MODIFIER_SETTINGS) {
|
||||
ClientProxy.logTranslate(action.name);
|
||||
EffortlessBuilding.logTranslate(player, "", action.name, "", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package nl.requios.effortlessbuilding.buildmode;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.network.PacketDistributor;
|
||||
@@ -19,7 +19,7 @@ public class ModeSettingsManager {
|
||||
//Retrieves the buildsettings of a player through the modifierCapability capability
|
||||
//Never returns null
|
||||
@Nonnull
|
||||
public static ModeSettings getModeSettings(EntityPlayer player) {
|
||||
public static ModeSettings getModeSettings(PlayerEntity player) {
|
||||
LazyOptional<ModeCapabilityManager.IModeCapability> modeCapability =
|
||||
player.getCapability(ModeCapabilityManager.modeCapability, null);
|
||||
|
||||
@@ -37,7 +37,7 @@ public class ModeSettingsManager {
|
||||
// throw new IllegalArgumentException("Player does not have modeCapability capability");
|
||||
}
|
||||
|
||||
public static void setModeSettings(EntityPlayer player, ModeSettings modeSettings) {
|
||||
public static void setModeSettings(PlayerEntity player, ModeSettings modeSettings) {
|
||||
if (player == null) {
|
||||
EffortlessBuilding.log("Cannot set buildmode settings, player is null");
|
||||
return;
|
||||
@@ -56,7 +56,7 @@ public class ModeSettingsManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static String sanitize(ModeSettings modeSettings, EntityPlayer player) {
|
||||
public static String sanitize(ModeSettings modeSettings, PlayerEntity player) {
|
||||
int maxReach = ReachHelper.getMaxReach(player);
|
||||
String error = "";
|
||||
|
||||
@@ -84,7 +84,7 @@ public class ModeSettingsManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static void handleNewPlayer(EntityPlayer player){
|
||||
public static void handleNewPlayer(PlayerEntity player){
|
||||
//Makes sure player has mode settings (if it doesnt it will create it)
|
||||
getModeSettings(player);
|
||||
|
||||
@@ -92,7 +92,7 @@ public class ModeSettingsManager {
|
||||
if (!player.world.isRemote) {
|
||||
//Send to client
|
||||
ModeSettingsMessage msg = new ModeSettingsMessage(getModeSettings(player));
|
||||
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (EntityPlayerMP) player), msg);
|
||||
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package nl.requios.effortlessbuilding.buildmode;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import nl.requios.effortlessbuilding.buildmode.buildmodes.DiagonalLine;
|
||||
import nl.requios.effortlessbuilding.buildmode.buildmodes.Floor;
|
||||
import nl.requios.effortlessbuilding.helper.ReachHelper;
|
||||
|
||||
import java.util.*;
|
||||
@@ -34,20 +32,20 @@ public abstract class ThreeClicksBuildMode extends BaseBuildMode {
|
||||
|
||||
//check if its not behind the player and its not too close and not too far
|
||||
//also check if raytrace from player to block does not intersect blocks
|
||||
public boolean isValid(Vec3d start, Vec3d look, int reach, EntityPlayer player, boolean skipRaytrace) {
|
||||
public boolean isValid(Vec3d start, Vec3d look, int reach, PlayerEntity player, boolean skipRaytrace) {
|
||||
|
||||
return BuildModes.isCriteriaValid(start, look, reach, player, skipRaytrace, lineBound, planeBound, distToPlayerSq);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(EntityPlayer player) {
|
||||
public void initialize(PlayerEntity player) {
|
||||
super.initialize(player);
|
||||
secondPosTable.put(player.getUniqueID(), BlockPos.ORIGIN);
|
||||
secondPosTable.put(player.getUniqueID(), BlockPos.ZERO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockPos> onRightClick(EntityPlayer player, BlockPos blockPos, EnumFacing sideHit, Vec3d hitVec, boolean skipRaytrace) {
|
||||
public List<BlockPos> onRightClick(PlayerEntity player, BlockPos blockPos, Direction sideHit, Vec3d hitVec, boolean skipRaytrace) {
|
||||
List<BlockPos> list = new ArrayList<>();
|
||||
|
||||
Dictionary<UUID, Integer> rightClickTable = player.world.isRemote ? rightClickClientTable : rightClickServerTable;
|
||||
@@ -89,7 +87,7 @@ public abstract class ThreeClicksBuildMode extends BaseBuildMode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockPos> findCoordinates(EntityPlayer player, BlockPos blockPos, boolean skipRaytrace) {
|
||||
public List<BlockPos> findCoordinates(PlayerEntity player, BlockPos blockPos, boolean skipRaytrace) {
|
||||
List<BlockPos> list = new ArrayList<>();
|
||||
Dictionary<UUID, Integer> rightClickTable = player.world.isRemote ? rightClickClientTable : rightClickServerTable;
|
||||
int rightClickNr = rightClickTable.get(player.getUniqueID());
|
||||
@@ -158,19 +156,19 @@ public abstract class ThreeClicksBuildMode extends BaseBuildMode {
|
||||
}
|
||||
|
||||
//Finds the place of the second block pos
|
||||
protected abstract BlockPos findSecondPos(EntityPlayer player, BlockPos firstPos, boolean skipRaytrace);
|
||||
protected abstract BlockPos findSecondPos(PlayerEntity player, BlockPos firstPos, boolean skipRaytrace);
|
||||
|
||||
//Finds the place of the third block pos
|
||||
protected abstract BlockPos findThirdPos(EntityPlayer player, BlockPos firstPos, BlockPos secondPos, boolean skipRaytrace);
|
||||
protected abstract BlockPos findThirdPos(PlayerEntity player, BlockPos firstPos, BlockPos secondPos, boolean skipRaytrace);
|
||||
|
||||
//After first and second pos are known, we want to visualize the blocks in a way (like floor for cube)
|
||||
protected abstract List<BlockPos> getIntermediateBlocks(EntityPlayer player, int x1, int y1, int z1, int x2, int y2, int z2);
|
||||
protected abstract List<BlockPos> getIntermediateBlocks(PlayerEntity player, int x1, int y1, int z1, int x2, int y2, int z2);
|
||||
|
||||
//After first, second and third pos are known, we want all the blocks
|
||||
protected abstract List<BlockPos> getFinalBlocks(EntityPlayer player, int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3);
|
||||
protected abstract List<BlockPos> getFinalBlocks(PlayerEntity player, int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3);
|
||||
|
||||
//Finds height after floor has been chosen in buildmodes with 3 clicks
|
||||
public static BlockPos findHeight(EntityPlayer player, BlockPos secondPos, boolean skipRaytrace) {
|
||||
public static BlockPos findHeight(PlayerEntity player, BlockPos secondPos, boolean skipRaytrace) {
|
||||
Vec3d look = player.getLookVec();
|
||||
Vec3d start = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package nl.requios.effortlessbuilding.buildmode;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import nl.requios.effortlessbuilding.helper.ReachHelper;
|
||||
@@ -14,7 +14,7 @@ import java.util.UUID;
|
||||
public abstract class TwoClicksBuildMode extends BaseBuildMode {
|
||||
|
||||
@Override
|
||||
public List<BlockPos> onRightClick(EntityPlayer player, BlockPos blockPos, EnumFacing sideHit, Vec3d hitVec, boolean skipRaytrace) {
|
||||
public List<BlockPos> onRightClick(PlayerEntity player, BlockPos blockPos, Direction sideHit, Vec3d hitVec, boolean skipRaytrace) {
|
||||
List<BlockPos> list = new ArrayList<>();
|
||||
|
||||
Dictionary<UUID, Integer> rightClickTable = player.world.isRemote ? rightClickClientTable : rightClickServerTable;
|
||||
@@ -44,7 +44,7 @@ public abstract class TwoClicksBuildMode extends BaseBuildMode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockPos> findCoordinates(EntityPlayer player, BlockPos blockPos, boolean skipRaytrace) {
|
||||
public List<BlockPos> findCoordinates(PlayerEntity player, BlockPos blockPos, boolean skipRaytrace) {
|
||||
List<BlockPos> list = new ArrayList<>();
|
||||
Dictionary<UUID, Integer> rightClickTable = player.world.isRemote ? rightClickClientTable : rightClickServerTable;
|
||||
int rightClickNr = rightClickTable.get(player.getUniqueID());
|
||||
@@ -79,8 +79,8 @@ public abstract class TwoClicksBuildMode extends BaseBuildMode {
|
||||
}
|
||||
|
||||
//Finds the place of the second block pos based on criteria (floor must be on same height as first click, wall on same plane etc)
|
||||
protected abstract BlockPos findSecondPos(EntityPlayer player, BlockPos firstPos, boolean skipRaytrace);
|
||||
protected abstract BlockPos findSecondPos(PlayerEntity player, BlockPos firstPos, boolean skipRaytrace);
|
||||
|
||||
//After first and second pos are known, we want all the blocks
|
||||
protected abstract List<BlockPos> getAllBlocks(EntityPlayer player, int x1, int y1, int z1, int x2, int y2, int z2);
|
||||
protected abstract List<BlockPos> getAllBlocks(PlayerEntity player, int x1, int y1, int z1, int x2, int y2, int z2);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import nl.requios.effortlessbuilding.buildmode.TwoClicksBuildMode;
|
||||
@@ -11,16 +11,16 @@ import java.util.*;
|
||||
public class Circle extends TwoClicksBuildMode {
|
||||
|
||||
@Override
|
||||
protected BlockPos findSecondPos(EntityPlayer player, BlockPos firstPos, boolean skipRaytrace) {
|
||||
protected BlockPos findSecondPos(PlayerEntity player, BlockPos firstPos, boolean skipRaytrace) {
|
||||
return Floor.findFloor(player, firstPos, skipRaytrace);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<BlockPos> getAllBlocks(EntityPlayer player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
protected List<BlockPos> getAllBlocks(PlayerEntity player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
return getCircleBlocks(player, x1, y1, z1, x2, y2, z2);
|
||||
}
|
||||
|
||||
public static List<BlockPos> getCircleBlocks(EntityPlayer player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
public static List<BlockPos> getCircleBlocks(PlayerEntity player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
List<BlockPos> list = new ArrayList<>();
|
||||
|
||||
float centerX = x1;
|
||||
|
||||
@@ -1,39 +1,35 @@
|
||||
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import nl.requios.effortlessbuilding.buildmode.IBuildMode;
|
||||
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
||||
import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode;
|
||||
import nl.requios.effortlessbuilding.helper.ReachHelper;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Cube extends ThreeClicksBuildMode {
|
||||
|
||||
@Override
|
||||
protected BlockPos findSecondPos(EntityPlayer player, BlockPos firstPos, boolean skipRaytrace) {
|
||||
protected BlockPos findSecondPos(PlayerEntity player, BlockPos firstPos, boolean skipRaytrace) {
|
||||
return Floor.findFloor(player, firstPos, skipRaytrace);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockPos findThirdPos(EntityPlayer player, BlockPos firstPos, BlockPos secondPos, boolean skipRaytrace) {
|
||||
protected BlockPos findThirdPos(PlayerEntity player, BlockPos firstPos, BlockPos secondPos, boolean skipRaytrace) {
|
||||
return findHeight(player, secondPos, skipRaytrace);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<BlockPos> getIntermediateBlocks(EntityPlayer player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
protected List<BlockPos> getIntermediateBlocks(PlayerEntity player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
return getFloorBlocksUsingCubeFill(player, x1, y1, z1, x2, y2, z2);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<BlockPos> getFinalBlocks(EntityPlayer player, int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3) {
|
||||
protected List<BlockPos> getFinalBlocks(PlayerEntity player, int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3) {
|
||||
return getCubeBlocks(player, x1, y1, z1, x3, y3, z3);
|
||||
}
|
||||
|
||||
public static List<BlockPos> getFloorBlocksUsingCubeFill(EntityPlayer player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
public static List<BlockPos> getFloorBlocksUsingCubeFill(PlayerEntity player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
List<BlockPos> list = new ArrayList<>();
|
||||
|
||||
if (ModeOptions.getCubeFill() == ModeOptions.ActionEnum.CUBE_SKELETON)
|
||||
@@ -44,7 +40,7 @@ public class Cube extends ThreeClicksBuildMode {
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<BlockPos> getCubeBlocks(EntityPlayer player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
public static List<BlockPos> getCubeBlocks(PlayerEntity player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
List<BlockPos> list = new ArrayList<>();
|
||||
|
||||
switch (ModeOptions.getCubeFill()) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode;
|
||||
|
||||
@@ -10,26 +10,26 @@ import java.util.List;
|
||||
public class Cylinder extends ThreeClicksBuildMode {
|
||||
|
||||
@Override
|
||||
public BlockPos findSecondPos(EntityPlayer player, BlockPos firstPos, boolean skipRaytrace) {
|
||||
public BlockPos findSecondPos(PlayerEntity player, BlockPos firstPos, boolean skipRaytrace) {
|
||||
return Floor.findFloor(player, firstPos, skipRaytrace);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos findThirdPos(EntityPlayer player, BlockPos firstPos, BlockPos secondPos, boolean skipRaytrace) {
|
||||
public BlockPos findThirdPos(PlayerEntity player, BlockPos firstPos, BlockPos secondPos, boolean skipRaytrace) {
|
||||
return findHeight(player, secondPos, skipRaytrace);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockPos> getIntermediateBlocks(EntityPlayer player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
public List<BlockPos> getIntermediateBlocks(PlayerEntity player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
return Circle.getCircleBlocks(player, x1, y1, z1, x2, y2, z2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockPos> getFinalBlocks(EntityPlayer player, int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3) {
|
||||
public List<BlockPos> getFinalBlocks(PlayerEntity player, int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3) {
|
||||
return getCylinderBlocks(player, x1, y1, z1, x2, y2, z2, x3, y3, z3);
|
||||
}
|
||||
|
||||
public static List<BlockPos> getCylinderBlocks(EntityPlayer player, int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3) {
|
||||
public static List<BlockPos> getCylinderBlocks(PlayerEntity player, int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3) {
|
||||
List<BlockPos> list = new ArrayList<>();
|
||||
|
||||
//Get circle blocks (using CIRCLE_START and FILL options built-in)
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode;
|
||||
import nl.requios.effortlessbuilding.helper.ReachHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -12,29 +11,29 @@ import java.util.List;
|
||||
public class DiagonalLine extends ThreeClicksBuildMode {
|
||||
|
||||
@Override
|
||||
protected BlockPos findSecondPos(EntityPlayer player, BlockPos firstPos, boolean skipRaytrace) {
|
||||
protected BlockPos findSecondPos(PlayerEntity player, BlockPos firstPos, boolean skipRaytrace) {
|
||||
return Floor.findFloor(player, firstPos, skipRaytrace);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockPos findThirdPos(EntityPlayer player, BlockPos firstPos, BlockPos secondPos, boolean skipRaytrace) {
|
||||
protected BlockPos findThirdPos(PlayerEntity player, BlockPos firstPos, BlockPos secondPos, boolean skipRaytrace) {
|
||||
return findHeight(player, secondPos, skipRaytrace);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<BlockPos> getIntermediateBlocks(EntityPlayer player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
protected List<BlockPos> getIntermediateBlocks(PlayerEntity player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
//Add diagonal line from first to second
|
||||
return getDiagonalLineBlocks(player, x1, y1, z1, x2, y2, z2, 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<BlockPos> getFinalBlocks(EntityPlayer player, int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3) {
|
||||
protected List<BlockPos> getFinalBlocks(PlayerEntity player, int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3) {
|
||||
//Add diagonal line from first to third
|
||||
return getDiagonalLineBlocks(player, x1, y1, z1, x3, y3, z3, 10);
|
||||
}
|
||||
|
||||
//Add diagonal line from first to second
|
||||
public static List<BlockPos> getDiagonalLineBlocks(EntityPlayer player, int x1, int y1, int z1, int x2, int y2, int z2, float sampleMultiplier) {
|
||||
public static List<BlockPos> getDiagonalLineBlocks(PlayerEntity player, int x1, int y1, int z1, int x2, int y2, int z2, float sampleMultiplier) {
|
||||
List<BlockPos> list = new ArrayList<>();
|
||||
|
||||
Vec3d first = new Vec3d(x1, y1, z1).add(0.5, 0.5, 0.5);
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode;
|
||||
import nl.requios.effortlessbuilding.helper.ReachHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -11,27 +10,27 @@ import java.util.List;
|
||||
public class DiagonalWall extends ThreeClicksBuildMode {
|
||||
|
||||
@Override
|
||||
protected BlockPos findSecondPos(EntityPlayer player, BlockPos firstPos, boolean skipRaytrace) {
|
||||
protected BlockPos findSecondPos(PlayerEntity player, BlockPos firstPos, boolean skipRaytrace) {
|
||||
return Floor.findFloor(player, firstPos, skipRaytrace);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockPos findThirdPos(EntityPlayer player, BlockPos firstPos, BlockPos secondPos, boolean skipRaytrace) {
|
||||
protected BlockPos findThirdPos(PlayerEntity player, BlockPos firstPos, BlockPos secondPos, boolean skipRaytrace) {
|
||||
return findHeight(player, secondPos, skipRaytrace);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<BlockPos> getIntermediateBlocks(EntityPlayer player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
protected List<BlockPos> getIntermediateBlocks(PlayerEntity player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
return DiagonalLine.getDiagonalLineBlocks(player, x1, y1, z1, x2, y2, z2, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<BlockPos> getFinalBlocks(EntityPlayer player, int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3) {
|
||||
protected List<BlockPos> getFinalBlocks(PlayerEntity player, int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3) {
|
||||
return getDiagonalWallBlocks(player, x1, y1, z1, x2, y2, z2, x3, y3, z3);
|
||||
}
|
||||
|
||||
//Add diagonal wall from first to second
|
||||
public static List<BlockPos> getDiagonalWallBlocks(EntityPlayer player, int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3) {
|
||||
public static List<BlockPos> getDiagonalWallBlocks(PlayerEntity player, int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3) {
|
||||
List<BlockPos> list = new ArrayList<>();
|
||||
|
||||
//Get diagonal line blocks
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
||||
@@ -23,18 +23,18 @@ public class Floor extends TwoClicksBuildMode {
|
||||
|
||||
//check if its not behind the player and its not too close and not too far
|
||||
//also check if raytrace from player to block does not intersect blocks
|
||||
public boolean isValid(Vec3d start, Vec3d look, int reach, EntityPlayer player, boolean skipRaytrace) {
|
||||
public boolean isValid(Vec3d start, Vec3d look, int reach, PlayerEntity player, boolean skipRaytrace) {
|
||||
|
||||
return BuildModes.isCriteriaValid(start, look, reach, player, skipRaytrace, planeBound, planeBound, distToPlayerSq);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockPos findSecondPos(EntityPlayer player, BlockPos firstPos, boolean skipRaytrace) {
|
||||
protected BlockPos findSecondPos(PlayerEntity player, BlockPos firstPos, boolean skipRaytrace) {
|
||||
return findFloor(player, firstPos, skipRaytrace);
|
||||
}
|
||||
|
||||
public static BlockPos findFloor(EntityPlayer player, BlockPos firstPos, boolean skipRaytrace) {
|
||||
public static BlockPos findFloor(PlayerEntity player, BlockPos firstPos, boolean skipRaytrace) {
|
||||
Vec3d look = player.getLookVec();
|
||||
Vec3d start = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ);
|
||||
|
||||
@@ -58,11 +58,11 @@ public class Floor extends TwoClicksBuildMode {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<BlockPos> getAllBlocks(EntityPlayer player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
protected List<BlockPos> getAllBlocks(PlayerEntity player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
return getFloorBlocks(player, x1, y1, z1, x2, y2, z2);
|
||||
}
|
||||
|
||||
public static List<BlockPos> getFloorBlocks(EntityPlayer player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
public static List<BlockPos> getFloorBlocks(PlayerEntity player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
List<BlockPos> list = new ArrayList<>();
|
||||
|
||||
if (ModeOptions.getFill() == ModeOptions.ActionEnum.FULL)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
||||
@@ -47,7 +47,7 @@ public class Line extends TwoClicksBuildMode {
|
||||
|
||||
//check if its not behind the player and its not too close and not too far
|
||||
//also check if raytrace from player to block does not intersect blocks
|
||||
public boolean isValid(Vec3d start, Vec3d look, int reach, EntityPlayer player, boolean skipRaytrace) {
|
||||
public boolean isValid(Vec3d start, Vec3d look, int reach, PlayerEntity player, boolean skipRaytrace) {
|
||||
|
||||
return BuildModes.isCriteriaValid(start, look, reach, player, skipRaytrace, lineBound, planeBound, distToPlayerSq);
|
||||
}
|
||||
@@ -55,11 +55,11 @@ public class Line extends TwoClicksBuildMode {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockPos findSecondPos(EntityPlayer player, BlockPos firstPos, boolean skipRaytrace) {
|
||||
protected BlockPos findSecondPos(PlayerEntity player, BlockPos firstPos, boolean skipRaytrace) {
|
||||
return findLine(player, firstPos, skipRaytrace);
|
||||
}
|
||||
|
||||
public static BlockPos findLine(EntityPlayer player, BlockPos firstPos, boolean skipRaytrace) {
|
||||
public static BlockPos findLine(PlayerEntity player, BlockPos firstPos, boolean skipRaytrace) {
|
||||
Vec3d look = player.getLookVec();
|
||||
Vec3d start = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ);
|
||||
|
||||
@@ -109,11 +109,11 @@ public class Line extends TwoClicksBuildMode {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<BlockPos> getAllBlocks(EntityPlayer player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
protected List<BlockPos> getAllBlocks(PlayerEntity player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
return getLineBlocks(player, x1, y1, z1, x2, y2, z2);
|
||||
}
|
||||
|
||||
public static List<BlockPos> getLineBlocks(EntityPlayer player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
public static List<BlockPos> getLineBlocks(PlayerEntity player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
List<BlockPos> list = new ArrayList<>();
|
||||
|
||||
if (x1 != x2) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import nl.requios.effortlessbuilding.buildmode.IBuildMode;
|
||||
@@ -11,31 +11,31 @@ import java.util.List;
|
||||
|
||||
public class Normal implements IBuildMode {
|
||||
@Override
|
||||
public void initialize(EntityPlayer player) {
|
||||
public void initialize(PlayerEntity player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockPos> onRightClick(EntityPlayer player, BlockPos blockPos, EnumFacing sideHit, Vec3d hitVec, boolean skipRaytrace) {
|
||||
public List<BlockPos> onRightClick(PlayerEntity player, BlockPos blockPos, Direction sideHit, Vec3d hitVec, boolean skipRaytrace) {
|
||||
List<BlockPos> list = new ArrayList<>();
|
||||
if (blockPos != null) list.add(blockPos);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockPos> findCoordinates(EntityPlayer player, BlockPos blockPos, boolean skipRaytrace) {
|
||||
public List<BlockPos> findCoordinates(PlayerEntity player, BlockPos blockPos, boolean skipRaytrace) {
|
||||
List<BlockPos> list = new ArrayList<>();
|
||||
if (blockPos != null) list.add(blockPos);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getSideHit(EntityPlayer player) {
|
||||
public Direction getSideHit(PlayerEntity player) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getHitVec(EntityPlayer player) {
|
||||
public Vec3d getHitVec(PlayerEntity player) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import nl.requios.effortlessbuilding.buildmode.IBuildMode;
|
||||
@@ -11,31 +11,31 @@ import java.util.List;
|
||||
|
||||
public class NormalPlus implements IBuildMode {
|
||||
@Override
|
||||
public void initialize(EntityPlayer player) {
|
||||
public void initialize(PlayerEntity player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockPos> onRightClick(EntityPlayer player, BlockPos blockPos, EnumFacing sideHit, Vec3d hitVec, boolean skipRaytrace) {
|
||||
public List<BlockPos> onRightClick(PlayerEntity player, BlockPos blockPos, Direction sideHit, Vec3d hitVec, boolean skipRaytrace) {
|
||||
List<BlockPos> list = new ArrayList<>();
|
||||
if (blockPos != null) list.add(blockPos);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockPos> findCoordinates(EntityPlayer player, BlockPos blockPos, boolean skipRaytrace) {
|
||||
public List<BlockPos> findCoordinates(PlayerEntity player, BlockPos blockPos, boolean skipRaytrace) {
|
||||
List<BlockPos> list = new ArrayList<>();
|
||||
if (blockPos != null) list.add(blockPos);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getSideHit(EntityPlayer player) {
|
||||
public Direction getSideHit(PlayerEntity player) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getHitVec(EntityPlayer player) {
|
||||
public Vec3d getHitVec(PlayerEntity player) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
||||
import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode;
|
||||
@@ -12,27 +12,27 @@ import java.util.List;
|
||||
public class SlopeFloor extends ThreeClicksBuildMode {
|
||||
|
||||
@Override
|
||||
protected BlockPos findSecondPos(EntityPlayer player, BlockPos firstPos, boolean skipRaytrace) {
|
||||
protected BlockPos findSecondPos(PlayerEntity player, BlockPos firstPos, boolean skipRaytrace) {
|
||||
return Floor.findFloor(player, firstPos, skipRaytrace);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockPos findThirdPos(EntityPlayer player, BlockPos firstPos, BlockPos secondPos, boolean skipRaytrace) {
|
||||
protected BlockPos findThirdPos(PlayerEntity player, BlockPos firstPos, BlockPos secondPos, boolean skipRaytrace) {
|
||||
return findHeight(player, secondPos, skipRaytrace);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<BlockPos> getIntermediateBlocks(EntityPlayer player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
protected List<BlockPos> getIntermediateBlocks(PlayerEntity player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
return Floor.getFloorBlocks(player, x1, y1, z1, x2, y2, z2);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<BlockPos> getFinalBlocks(EntityPlayer player, int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3) {
|
||||
protected List<BlockPos> getFinalBlocks(PlayerEntity player, int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3) {
|
||||
return getSlopeFloorBlocks(player, x1, y1, z1, x2, y2, z2, x3, y3, z3);
|
||||
}
|
||||
|
||||
//Add slope floor from first to second
|
||||
public static List<BlockPos> getSlopeFloorBlocks(EntityPlayer player, int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3) {
|
||||
public static List<BlockPos> getSlopeFloorBlocks(PlayerEntity player, int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3) {
|
||||
List<BlockPos> list = new ArrayList<>();
|
||||
|
||||
int axisLimit = ReachHelper.getMaxBlocksPerAxis(player);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
||||
@@ -12,26 +12,26 @@ import java.util.List;
|
||||
public class Sphere extends ThreeClicksBuildMode {
|
||||
|
||||
@Override
|
||||
public BlockPos findSecondPos(EntityPlayer player, BlockPos firstPos, boolean skipRaytrace) {
|
||||
public BlockPos findSecondPos(PlayerEntity player, BlockPos firstPos, boolean skipRaytrace) {
|
||||
return Floor.findFloor(player, firstPos, skipRaytrace);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos findThirdPos(EntityPlayer player, BlockPos firstPos, BlockPos secondPos, boolean skipRaytrace) {
|
||||
public BlockPos findThirdPos(PlayerEntity player, BlockPos firstPos, BlockPos secondPos, boolean skipRaytrace) {
|
||||
return findHeight(player, secondPos, skipRaytrace);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockPos> getIntermediateBlocks(EntityPlayer player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
public List<BlockPos> getIntermediateBlocks(PlayerEntity player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
return Circle.getCircleBlocks(player, x1, y1, z1, x2, y2, z2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockPos> getFinalBlocks(EntityPlayer player, int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3) {
|
||||
public List<BlockPos> getFinalBlocks(PlayerEntity player, int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3) {
|
||||
return getSphereBlocks(player, x1, y1, z1, x2, y2, z2, x3, y3, z3);
|
||||
}
|
||||
|
||||
public static List<BlockPos> getSphereBlocks(EntityPlayer player, int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3) {
|
||||
public static List<BlockPos> getSphereBlocks(PlayerEntity player, int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3) {
|
||||
List<BlockPos> list = new ArrayList<>();
|
||||
|
||||
float centerX = x1;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
||||
@@ -26,18 +26,18 @@ public class Wall extends TwoClicksBuildMode {
|
||||
|
||||
//check if its not behind the player and its not too close and not too far
|
||||
//also check if raytrace from player to block does not intersect blocks
|
||||
public boolean isValid(Vec3d start, Vec3d look, int reach, EntityPlayer player, boolean skipRaytrace) {
|
||||
public boolean isValid(Vec3d start, Vec3d look, int reach, PlayerEntity player, boolean skipRaytrace) {
|
||||
|
||||
return BuildModes.isCriteriaValid(start, look, reach, player, skipRaytrace, planeBound, planeBound, distToPlayerSq);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockPos findSecondPos(EntityPlayer player, BlockPos firstPos, boolean skipRaytrace) {
|
||||
protected BlockPos findSecondPos(PlayerEntity player, BlockPos firstPos, boolean skipRaytrace) {
|
||||
return findWall(player, firstPos, skipRaytrace);
|
||||
}
|
||||
|
||||
public static BlockPos findWall(EntityPlayer player, BlockPos firstPos, boolean skipRaytrace) {
|
||||
public static BlockPos findWall(PlayerEntity player, BlockPos firstPos, boolean skipRaytrace) {
|
||||
Vec3d look = player.getLookVec();
|
||||
Vec3d start = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ);
|
||||
|
||||
@@ -76,11 +76,11 @@ public class Wall extends TwoClicksBuildMode {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<BlockPos> getAllBlocks(EntityPlayer player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
protected List<BlockPos> getAllBlocks(PlayerEntity player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
return getWallBlocks(player, x1, y1, z1, x2, y2, z2);
|
||||
}
|
||||
|
||||
public static List<BlockPos> getWallBlocks(EntityPlayer player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
public static List<BlockPos> getWallBlocks(PlayerEntity player, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
List<BlockPos> list = new ArrayList<>();
|
||||
|
||||
if (x1 == x2) {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package nl.requios.effortlessbuilding.buildmodifier;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
@@ -18,7 +18,7 @@ public class Array {
|
||||
|
||||
public static class ArraySettings{
|
||||
public boolean enabled = false;
|
||||
public BlockPos offset = BlockPos.ORIGIN;
|
||||
public BlockPos offset = BlockPos.ZERO;
|
||||
public int count = 5;
|
||||
|
||||
public ArraySettings() {
|
||||
@@ -41,7 +41,7 @@ public class Array {
|
||||
}
|
||||
}
|
||||
|
||||
public static List<BlockPos> findCoordinates(EntityPlayer player, BlockPos startPos) {
|
||||
public static List<BlockPos> findCoordinates(PlayerEntity player, BlockPos startPos) {
|
||||
List<BlockPos> coordinates = new ArrayList<>();
|
||||
|
||||
//find arraysettings for the player
|
||||
@@ -59,8 +59,8 @@ public class Array {
|
||||
return coordinates;
|
||||
}
|
||||
|
||||
public static List<IBlockState> findBlockStates(EntityPlayer player, BlockPos startPos, IBlockState blockState, ItemStack itemStack, List<ItemStack> itemStacks) {
|
||||
List<IBlockState> blockStates = new ArrayList<>();
|
||||
public static List<BlockState> findBlockStates(PlayerEntity player, BlockPos startPos, BlockState blockState, ItemStack itemStack, List<ItemStack> itemStacks) {
|
||||
List<BlockState> blockStates = new ArrayList<>();
|
||||
|
||||
//find arraysettings for the player that placed the block
|
||||
ArraySettings a = ModifierSettingsManager.getModifierSettings(player).getArraySettings();
|
||||
@@ -82,7 +82,7 @@ public class Array {
|
||||
if (bagInventory != null) {
|
||||
itemStack = ItemRandomizerBag.pickRandomStack(bagInventory);
|
||||
blockState = BuildModifiers
|
||||
.getBlockStateFromItem(itemStack, player, startPos, EnumFacing.UP, new Vec3d(0, 0, 0), EnumHand.MAIN_HAND);
|
||||
.getBlockStateFromItem(itemStack, player, startPos, Direction.UP, new Vec3d(0, 0, 0), Hand.MAIN_HAND);
|
||||
}
|
||||
|
||||
//blockState = blockState.getBlock().getStateForPlacement(player.world, pos, )
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package nl.requios.effortlessbuilding.buildmodifier;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
@@ -8,13 +8,13 @@ import java.util.List;
|
||||
|
||||
public class BlockSet {
|
||||
private List<BlockPos> coordinates;
|
||||
private List<IBlockState> previousBlockStates;
|
||||
private List<IBlockState> newBlockStates;
|
||||
private List<BlockState> previousBlockStates;
|
||||
private List<BlockState> newBlockStates;
|
||||
private Vec3d hitVec;
|
||||
private BlockPos firstPos;
|
||||
private BlockPos secondPos;
|
||||
|
||||
public BlockSet(List<BlockPos> coordinates, List<IBlockState> previousBlockStates, List<IBlockState> newBlockStates, Vec3d hitVec,
|
||||
public BlockSet(List<BlockPos> coordinates, List<BlockState> previousBlockStates, List<BlockState> newBlockStates, Vec3d hitVec,
|
||||
BlockPos firstPos, BlockPos secondPos) {
|
||||
this.coordinates = coordinates;
|
||||
this.previousBlockStates = previousBlockStates;
|
||||
@@ -28,11 +28,11 @@ public class BlockSet {
|
||||
return coordinates;
|
||||
}
|
||||
|
||||
public List<IBlockState> getPreviousBlockStates() {
|
||||
public List<BlockState> getPreviousBlockStates() {
|
||||
return previousBlockStates;
|
||||
}
|
||||
|
||||
public List<IBlockState> getNewBlockStates() {
|
||||
public List<BlockState> getNewBlockStates() {
|
||||
return newBlockStates;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
package nl.requios.effortlessbuilding.buildmodifier;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
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.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
import nl.requios.effortlessbuilding.compatibility.CompatHelper;
|
||||
import nl.requios.effortlessbuilding.helper.InventoryHelper;
|
||||
import nl.requios.effortlessbuilding.helper.SurvivalHelper;
|
||||
@@ -24,7 +25,7 @@ import java.util.*;
|
||||
public class BuildModifiers {
|
||||
|
||||
//Called from BuildModes
|
||||
public static void onBlockPlaced(EntityPlayer player, List<BlockPos> startCoordinates, EnumFacing sideHit, Vec3d hitVec, boolean placeStartPos) {
|
||||
public static void onBlockPlaced(PlayerEntity player, List<BlockPos> startCoordinates, Direction sideHit, Vec3d hitVec, boolean placeStartPos) {
|
||||
World world = player.world;
|
||||
ItemRandomizerBag.renewRandomness();
|
||||
|
||||
@@ -34,14 +35,14 @@ public class BuildModifiers {
|
||||
//find coordinates and blockstates
|
||||
List<BlockPos> coordinates = findCoordinates(player, startCoordinates);
|
||||
List<ItemStack> itemStacks = new ArrayList<>();
|
||||
List<IBlockState> blockStates = findBlockStates(player, startCoordinates, hitVec, sideHit, itemStacks);
|
||||
List<BlockState> blockStates = findBlockStates(player, startCoordinates, hitVec, sideHit, itemStacks);
|
||||
|
||||
//check if valid blockstates
|
||||
if (blockStates.size() == 0 || coordinates.size() != blockStates.size()) return;
|
||||
|
||||
//remember previous blockstates for undo
|
||||
List<IBlockState> previousBlockStates = new ArrayList<>(coordinates.size());
|
||||
List<IBlockState> newBlockStates = new ArrayList<>(coordinates.size());
|
||||
List<BlockState> previousBlockStates = new ArrayList<>(coordinates.size());
|
||||
List<BlockState> newBlockStates = new ArrayList<>(coordinates.size());
|
||||
for (BlockPos coordinate : coordinates) {
|
||||
previousBlockStates.add(world.getBlockState(coordinate));
|
||||
}
|
||||
@@ -57,17 +58,17 @@ public class BuildModifiers {
|
||||
//place blocks
|
||||
for (int i = placeStartPos ? 0 : 1; i < coordinates.size(); i++) {
|
||||
BlockPos blockPos = coordinates.get(i);
|
||||
IBlockState blockState = blockStates.get(i);
|
||||
BlockState blockState = blockStates.get(i);
|
||||
ItemStack itemStack = itemStacks.get(i);
|
||||
|
||||
if (world.isBlockLoaded(blockPos, true)) {
|
||||
if (world.isBlockPresent(blockPos)) {
|
||||
//check itemstack empty
|
||||
if (itemStack.isEmpty()) {
|
||||
//try to find new stack, otherwise continue
|
||||
itemStack = InventoryHelper.findItemStackInInventory(player, blockState.getBlock());
|
||||
if (itemStack.isEmpty()) continue;
|
||||
}
|
||||
SurvivalHelper.placeBlock(world, player, blockPos, blockState, itemStack, EnumFacing.UP, hitVec, false, false, false);
|
||||
SurvivalHelper.placeBlock(world, player, blockPos, blockState, itemStack, Direction.UP, hitVec, false, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +92,7 @@ public class BuildModifiers {
|
||||
}
|
||||
}
|
||||
|
||||
public static void onBlockBroken(EntityPlayer player, List<BlockPos> startCoordinates, boolean breakStartPos) {
|
||||
public static void onBlockBroken(PlayerEntity player, List<BlockPos> startCoordinates, boolean breakStartPos) {
|
||||
World world = player.world;
|
||||
|
||||
List<BlockPos> coordinates = findCoordinates(player, startCoordinates);
|
||||
@@ -99,8 +100,8 @@ public class BuildModifiers {
|
||||
if (coordinates.isEmpty()) return;
|
||||
|
||||
//remember previous blockstates for undo
|
||||
List<IBlockState> previousBlockStates = new ArrayList<>(coordinates.size());
|
||||
List<IBlockState> newBlockStates = new ArrayList<>(coordinates.size());
|
||||
List<BlockState> previousBlockStates = new ArrayList<>(coordinates.size());
|
||||
List<BlockState> newBlockStates = new ArrayList<>(coordinates.size());
|
||||
for (BlockPos coordinate : coordinates) {
|
||||
previousBlockStates.add(world.getBlockState(coordinate));
|
||||
}
|
||||
@@ -122,7 +123,7 @@ public class BuildModifiers {
|
||||
//break all those blocks
|
||||
for (int i = breakStartPos ? 0 : 1; i < coordinates.size(); i++) {
|
||||
BlockPos coordinate = coordinates.get(i);
|
||||
if (world.isBlockLoaded(coordinate, false)) {
|
||||
if (world.isBlockPresent(coordinate) && !world.isAirBlock(coordinate)) {
|
||||
if (!onlyInstaBreaking || world.getBlockState(coordinate).getBlockHardness(world, coordinate) == 0f) {
|
||||
SurvivalHelper.breakBlock(world, player, coordinate, false);
|
||||
}
|
||||
@@ -147,7 +148,7 @@ public class BuildModifiers {
|
||||
|
||||
}
|
||||
|
||||
public static List<BlockPos> findCoordinates(EntityPlayer player, List<BlockPos> posList) {
|
||||
public static List<BlockPos> findCoordinates(PlayerEntity player, List<BlockPos> posList) {
|
||||
List<BlockPos> coordinates = new ArrayList<>();
|
||||
//Add current blocks being placed too
|
||||
coordinates.addAll(posList);
|
||||
@@ -168,18 +169,18 @@ public class BuildModifiers {
|
||||
return coordinates;
|
||||
}
|
||||
|
||||
public static List<BlockPos> findCoordinates(EntityPlayer player, BlockPos blockPos) {
|
||||
public static List<BlockPos> findCoordinates(PlayerEntity player, BlockPos blockPos) {
|
||||
return findCoordinates(player, new ArrayList<>(Arrays.asList(blockPos)));
|
||||
}
|
||||
|
||||
public static List<IBlockState> findBlockStates(EntityPlayer player, List<BlockPos> posList, Vec3d hitVec, EnumFacing facing, List<ItemStack> itemStacks) {
|
||||
List<IBlockState> blockStates = new ArrayList<>();
|
||||
public static List<BlockState> findBlockStates(PlayerEntity player, List<BlockPos> posList, Vec3d hitVec, Direction facing, List<ItemStack> itemStacks) {
|
||||
List<BlockState> blockStates = new ArrayList<>();
|
||||
itemStacks.clear();
|
||||
|
||||
//Get itemstack
|
||||
ItemStack itemStack = player.getHeldItem(EnumHand.MAIN_HAND);
|
||||
ItemStack itemStack = player.getHeldItem(Hand.MAIN_HAND);
|
||||
if (itemStack.isEmpty() || !CompatHelper.isItemBlockProxy(itemStack)) {
|
||||
itemStack = player.getHeldItem(EnumHand.OFF_HAND);
|
||||
itemStack = player.getHeldItem(Hand.OFF_HAND);
|
||||
}
|
||||
if (itemStack.isEmpty() || !CompatHelper.isItemBlockProxy(itemStack)) {
|
||||
return blockStates;
|
||||
@@ -187,22 +188,22 @@ public class BuildModifiers {
|
||||
|
||||
//Get ItemBlock stack
|
||||
ItemStack itemBlock = ItemStack.EMPTY;
|
||||
if (itemStack.getItem() instanceof ItemBlock) itemBlock = itemStack;
|
||||
if (itemStack.getItem() instanceof BlockItem) itemBlock = itemStack;
|
||||
else itemBlock = CompatHelper.getItemBlockFromStack(itemStack);
|
||||
ItemRandomizerBag.resetRandomness();
|
||||
|
||||
//Add blocks in posList first
|
||||
for (BlockPos blockPos : posList) {
|
||||
if (!(itemStack.getItem() instanceof ItemBlock)) itemBlock = CompatHelper.getItemBlockFromStack(itemStack);
|
||||
IBlockState blockState = getBlockStateFromItem(itemBlock, player, blockPos, facing, hitVec, EnumHand.MAIN_HAND);
|
||||
if (!(itemStack.getItem() instanceof BlockItem)) itemBlock = CompatHelper.getItemBlockFromStack(itemStack);
|
||||
BlockState blockState = getBlockStateFromItem(itemBlock, player, blockPos, facing, hitVec, Hand.MAIN_HAND);
|
||||
blockStates.add(blockState);
|
||||
itemStacks.add(itemBlock);
|
||||
}
|
||||
|
||||
for (BlockPos blockPos : posList) {
|
||||
IBlockState blockState = getBlockStateFromItem(itemBlock, player, blockPos, facing, hitVec, EnumHand.MAIN_HAND);
|
||||
BlockState blockState = getBlockStateFromItem(itemBlock, player, blockPos, facing, hitVec, Hand.MAIN_HAND);
|
||||
|
||||
List<IBlockState> arrayBlockStates = Array.findBlockStates(player, blockPos, blockState, itemStack, itemStacks);
|
||||
List<BlockState> arrayBlockStates = Array.findBlockStates(player, blockPos, blockState, itemStack, itemStacks);
|
||||
blockStates.addAll(arrayBlockStates);
|
||||
blockStates.addAll(Mirror.findBlockStates(player, blockPos, blockState, itemStack, itemStacks));
|
||||
blockStates.addAll(RadialMirror.findBlockStates(player, blockPos, blockState, itemStack, itemStacks));
|
||||
@@ -210,7 +211,7 @@ public class BuildModifiers {
|
||||
List<BlockPos> arrayCoordinates = Array.findCoordinates(player, blockPos);
|
||||
for (int i = 0; i < arrayCoordinates.size(); i++) {
|
||||
BlockPos coordinate = arrayCoordinates.get(i);
|
||||
IBlockState blockState1 = arrayBlockStates.get(i);
|
||||
BlockState blockState1 = arrayBlockStates.get(i);
|
||||
blockStates.addAll(Mirror.findBlockStates(player, coordinate, blockState1, itemStack, itemStacks));
|
||||
blockStates.addAll(RadialMirror.findBlockStates(player, coordinate, blockState1, itemStack, itemStacks));
|
||||
}
|
||||
@@ -235,9 +236,8 @@ public class BuildModifiers {
|
||||
modifierSettings.doQuickReplace();
|
||||
}
|
||||
|
||||
public static IBlockState getBlockStateFromItem(ItemStack itemStack, EntityPlayer player, BlockPos blockPos, EnumFacing facing, Vec3d hitVec, EnumHand hand) {
|
||||
return Block.getBlockFromItem(itemStack.getItem()).getStateForPlacement(new BlockItemUseContext(player.world, player, itemStack, blockPos, facing,
|
||||
((float) hitVec.x), ((float) hitVec.y), ((float) hitVec.z)));
|
||||
public static BlockState getBlockStateFromItem(ItemStack itemStack, PlayerEntity player, BlockPos blockPos, Direction facing, Vec3d hitVec, Hand hand) {
|
||||
return Block.getBlockFromItem(itemStack.getItem()).getStateForPlacement(new BlockItemUseContext(new ItemUseContext(player, hand, new BlockRayTraceResult(hitVec, facing, blockPos, false))));
|
||||
}
|
||||
|
||||
//Returns true if equal (or both null)
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package nl.requios.effortlessbuilding.buildmodifier;
|
||||
|
||||
import net.minecraft.block.BlockDirectional;
|
||||
import net.minecraft.block.BlockDispenser;
|
||||
import net.minecraft.block.BlockSlab;
|
||||
import net.minecraft.block.BlockStairs;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.StairsBlock;
|
||||
import net.minecraft.block.DirectionalBlock;
|
||||
import net.minecraft.block.SlabBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.state.properties.Half;
|
||||
import net.minecraft.state.properties.SlabType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
@@ -47,7 +47,7 @@ public class Mirror {
|
||||
}
|
||||
}
|
||||
|
||||
public static List<BlockPos> findCoordinates(EntityPlayer player, BlockPos startPos) {
|
||||
public static List<BlockPos> findCoordinates(PlayerEntity player, BlockPos startPos) {
|
||||
List<BlockPos> coordinates = new ArrayList<>();
|
||||
|
||||
//find mirrorsettings for the player
|
||||
@@ -87,8 +87,8 @@ public class Mirror {
|
||||
coordinates.add(newBlockPos);
|
||||
}
|
||||
|
||||
public static List<IBlockState> findBlockStates(EntityPlayer player, BlockPos startPos, IBlockState blockState, ItemStack itemStack, List<ItemStack> itemStacks) {
|
||||
List<IBlockState> blockStates = new ArrayList<>();
|
||||
public static List<BlockState> findBlockStates(PlayerEntity player, BlockPos startPos, BlockState blockState, ItemStack itemStack, List<ItemStack> itemStacks) {
|
||||
List<BlockState> blockStates = new ArrayList<>();
|
||||
|
||||
//find mirrorsettings for the player
|
||||
MirrorSettings m = ModifierSettingsManager.getModifierSettings(player).getMirrorSettings();
|
||||
@@ -100,15 +100,15 @@ public class Mirror {
|
||||
bagInventory = ItemRandomizerBag.getBagInventory(itemStack);
|
||||
}
|
||||
|
||||
if (m.mirrorX) blockStateMirrorX(player, m, startPos, blockState, bagInventory, itemStack, EnumHand.MAIN_HAND, blockStates, itemStacks);
|
||||
if (m.mirrorY) blockStateMirrorY(player, m, startPos, blockState, bagInventory, itemStack, EnumHand.MAIN_HAND, blockStates, itemStacks);
|
||||
if (m.mirrorZ) blockStateMirrorZ(player, m, startPos, blockState, bagInventory, itemStack, EnumHand.MAIN_HAND, blockStates, itemStacks);
|
||||
if (m.mirrorX) blockStateMirrorX(player, m, startPos, blockState, bagInventory, itemStack, Hand.MAIN_HAND, blockStates, itemStacks);
|
||||
if (m.mirrorY) blockStateMirrorY(player, m, startPos, blockState, bagInventory, itemStack, Hand.MAIN_HAND, blockStates, itemStacks);
|
||||
if (m.mirrorZ) blockStateMirrorZ(player, m, startPos, blockState, bagInventory, itemStack, Hand.MAIN_HAND, blockStates, itemStacks);
|
||||
|
||||
return blockStates;
|
||||
}
|
||||
|
||||
private static void blockStateMirrorX(EntityPlayer player, MirrorSettings m, BlockPos oldBlockPos, IBlockState oldBlockState,
|
||||
IItemHandler bagInventory, ItemStack itemStack, EnumHand hand, List<IBlockState> blockStates, List<ItemStack> itemStacks) {
|
||||
private static void blockStateMirrorX(PlayerEntity player, MirrorSettings m, BlockPos oldBlockPos, BlockState oldBlockState,
|
||||
IItemHandler bagInventory, ItemStack itemStack, Hand hand, List<BlockState> blockStates, List<ItemStack> itemStacks) {
|
||||
//find mirror position
|
||||
double x = m.position.x + (m.position.x - oldBlockPos.getX() - 0.5);
|
||||
BlockPos newBlockPos = new BlockPos(x, oldBlockPos.getY(), oldBlockPos.getZ());
|
||||
@@ -116,11 +116,11 @@ public class Mirror {
|
||||
//Randomizer bag synergy
|
||||
if (bagInventory != null) {
|
||||
itemStack = ItemRandomizerBag.pickRandomStack(bagInventory);
|
||||
oldBlockState = BuildModifiers.getBlockStateFromItem(itemStack, player, oldBlockPos, EnumFacing.UP, new Vec3d(0, 0, 0), hand);
|
||||
oldBlockState = BuildModifiers.getBlockStateFromItem(itemStack, player, oldBlockPos, Direction.UP, new Vec3d(0, 0, 0), hand);
|
||||
}
|
||||
|
||||
//Find blockstate
|
||||
IBlockState newBlockState = oldBlockState == null ? null : oldBlockState.mirror(net.minecraft.util.Mirror.FRONT_BACK);
|
||||
BlockState newBlockState = oldBlockState == null ? null : oldBlockState.mirror(net.minecraft.util.Mirror.FRONT_BACK);
|
||||
|
||||
//Store blockstate and itemstack
|
||||
blockStates.add(newBlockState);
|
||||
@@ -130,8 +130,8 @@ public class Mirror {
|
||||
if (m.mirrorZ) blockStateMirrorZ(player, m, newBlockPos, newBlockState, bagInventory, itemStack, hand, blockStates, itemStacks);
|
||||
}
|
||||
|
||||
private static void blockStateMirrorY(EntityPlayer player, MirrorSettings m, BlockPos oldBlockPos, IBlockState oldBlockState,
|
||||
IItemHandler bagInventory, ItemStack itemStack, EnumHand hand, List<IBlockState> blockStates, List<ItemStack> itemStacks) {
|
||||
private static void blockStateMirrorY(PlayerEntity player, MirrorSettings m, BlockPos oldBlockPos, BlockState oldBlockState,
|
||||
IItemHandler bagInventory, ItemStack itemStack, Hand hand, List<BlockState> blockStates, List<ItemStack> itemStacks) {
|
||||
//find mirror position
|
||||
double y = m.position.y + (m.position.y - oldBlockPos.getY() - 0.5);
|
||||
BlockPos newBlockPos = new BlockPos(oldBlockPos.getX(), y, oldBlockPos.getZ());
|
||||
@@ -139,11 +139,11 @@ public class Mirror {
|
||||
//Randomizer bag synergy
|
||||
if (bagInventory != null) {
|
||||
itemStack = ItemRandomizerBag.pickRandomStack(bagInventory);
|
||||
oldBlockState = BuildModifiers.getBlockStateFromItem(itemStack, player, oldBlockPos, EnumFacing.UP, new Vec3d(0, 0, 0), hand);
|
||||
oldBlockState = BuildModifiers.getBlockStateFromItem(itemStack, player, oldBlockPos, Direction.UP, new Vec3d(0, 0, 0), hand);
|
||||
}
|
||||
|
||||
//Find blockstate
|
||||
IBlockState newBlockState = oldBlockState == null ? null : getVerticalMirror(oldBlockState);
|
||||
BlockState newBlockState = oldBlockState == null ? null : getVerticalMirror(oldBlockState);
|
||||
|
||||
//Store blockstate and itemstack
|
||||
blockStates.add(newBlockState);
|
||||
@@ -152,8 +152,8 @@ public class Mirror {
|
||||
if (m.mirrorZ) blockStateMirrorZ(player, m, newBlockPos, newBlockState, bagInventory, itemStack, hand, blockStates, itemStacks);
|
||||
}
|
||||
|
||||
private static void blockStateMirrorZ(EntityPlayer player, MirrorSettings m, BlockPos oldBlockPos, IBlockState oldBlockState,
|
||||
IItemHandler bagInventory, ItemStack itemStack, EnumHand hand, List<IBlockState> blockStates, List<ItemStack> itemStacks) {
|
||||
private static void blockStateMirrorZ(PlayerEntity player, MirrorSettings m, BlockPos oldBlockPos, BlockState oldBlockState,
|
||||
IItemHandler bagInventory, ItemStack itemStack, Hand hand, List<BlockState> blockStates, List<ItemStack> itemStacks) {
|
||||
//find mirror position
|
||||
double z = m.position.z + (m.position.z - oldBlockPos.getZ() - 0.5);
|
||||
BlockPos newBlockPos = new BlockPos(oldBlockPos.getX(), oldBlockPos.getY(), z);
|
||||
@@ -161,11 +161,11 @@ public class Mirror {
|
||||
//Randomizer bag synergy
|
||||
if (bagInventory != null) {
|
||||
itemStack = ItemRandomizerBag.pickRandomStack(bagInventory);
|
||||
oldBlockState = BuildModifiers.getBlockStateFromItem(itemStack, player, oldBlockPos, EnumFacing.UP, new Vec3d(0, 0, 0), hand);
|
||||
oldBlockState = BuildModifiers.getBlockStateFromItem(itemStack, player, oldBlockPos, Direction.UP, new Vec3d(0, 0, 0), hand);
|
||||
}
|
||||
|
||||
//Find blockstate
|
||||
IBlockState newBlockState = oldBlockState == null ? null : oldBlockState.mirror(net.minecraft.util.Mirror.LEFT_RIGHT);
|
||||
BlockState newBlockState = oldBlockState == null ? null : oldBlockState.mirror(net.minecraft.util.Mirror.LEFT_RIGHT);
|
||||
|
||||
//Store blockstate and itemstack
|
||||
blockStates.add(newBlockState);
|
||||
@@ -184,42 +184,42 @@ public class Mirror {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static IBlockState getVerticalMirror(IBlockState blockState) {
|
||||
private static BlockState getVerticalMirror(BlockState blockState) {
|
||||
//Stairs
|
||||
if (blockState.getBlock() instanceof BlockStairs) {
|
||||
if (blockState.get(BlockStairs.HALF) == Half.BOTTOM) {
|
||||
return blockState.with(BlockStairs.HALF, Half.TOP);
|
||||
if (blockState.getBlock() instanceof StairsBlock) {
|
||||
if (blockState.get(StairsBlock.HALF) == Half.BOTTOM) {
|
||||
return blockState.with(StairsBlock.HALF, Half.TOP);
|
||||
} else {
|
||||
return blockState.with(BlockStairs.HALF, Half.BOTTOM);
|
||||
return blockState.with(StairsBlock.HALF, Half.BOTTOM);
|
||||
}
|
||||
}
|
||||
|
||||
//Slabs
|
||||
if (blockState.getBlock() instanceof BlockSlab) {
|
||||
if (blockState.get(BlockSlab.TYPE) == SlabType.DOUBLE) {
|
||||
if (blockState.getBlock() instanceof SlabBlock) {
|
||||
if (blockState.get(SlabBlock.TYPE) == SlabType.DOUBLE) {
|
||||
return blockState;
|
||||
} else if (blockState.get(BlockSlab.TYPE) == SlabType.BOTTOM) {
|
||||
return blockState.with(BlockSlab.TYPE, SlabType.TOP);
|
||||
} else if (blockState.get(SlabBlock.TYPE) == SlabType.BOTTOM) {
|
||||
return blockState.with(SlabBlock.TYPE, SlabType.TOP);
|
||||
} else {
|
||||
return blockState.with(BlockSlab.TYPE, SlabType.BOTTOM);
|
||||
return blockState.with(SlabBlock.TYPE, SlabType.BOTTOM);
|
||||
}
|
||||
}
|
||||
|
||||
//Buttons, endrod, observer, piston
|
||||
if (blockState.getBlock() instanceof BlockDirectional) {
|
||||
if (blockState.get(BlockDirectional.FACING) == EnumFacing.DOWN) {
|
||||
return blockState.with(BlockDirectional.FACING, EnumFacing.UP);
|
||||
} else if (blockState.get(BlockDirectional.FACING) == EnumFacing.UP) {
|
||||
return blockState.with(BlockDirectional.FACING, EnumFacing.DOWN);
|
||||
if (blockState.getBlock() instanceof DirectionalBlock) {
|
||||
if (blockState.get(DirectionalBlock.FACING) == Direction.DOWN) {
|
||||
return blockState.with(DirectionalBlock.FACING, Direction.UP);
|
||||
} else if (blockState.get(DirectionalBlock.FACING) == Direction.UP) {
|
||||
return blockState.with(DirectionalBlock.FACING, Direction.DOWN);
|
||||
}
|
||||
}
|
||||
|
||||
//Dispenser, dropper
|
||||
if (blockState.getBlock() instanceof BlockDispenser) {
|
||||
if (blockState.get(BlockDispenser.FACING) == EnumFacing.DOWN) {
|
||||
return blockState.with(BlockDispenser.FACING, EnumFacing.UP);
|
||||
} else if (blockState.get(BlockDispenser.FACING) == EnumFacing.UP) {
|
||||
return blockState.with(BlockDispenser.FACING, EnumFacing.DOWN);
|
||||
if (blockState.getBlock() instanceof DispenserBlock) {
|
||||
if (blockState.get(DispenserBlock.FACING) == Direction.DOWN) {
|
||||
return blockState.with(DispenserBlock.FACING, Direction.UP);
|
||||
} else if (blockState.get(DispenserBlock.FACING) == Direction.UP) {
|
||||
return blockState.with(DispenserBlock.FACING, Direction.DOWN);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package nl.requios.effortlessbuilding.buildmodifier;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.network.PacketDistributor;
|
||||
@@ -13,8 +13,6 @@ import nl.requios.effortlessbuilding.network.ModifierSettingsMessage;
|
||||
import nl.requios.effortlessbuilding.network.PacketHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
public class ModifierSettingsManager {
|
||||
@@ -22,7 +20,7 @@ public class ModifierSettingsManager {
|
||||
//Retrieves the buildsettings of a player through the modifierCapability capability
|
||||
//Never returns null
|
||||
@Nonnull
|
||||
public static ModifierSettings getModifierSettings(EntityPlayer player){
|
||||
public static ModifierSettings getModifierSettings(PlayerEntity player){
|
||||
LazyOptional<ModifierCapabilityManager.IModifierCapability> modifierCapability =
|
||||
player.getCapability(ModifierCapabilityManager.modifierCapability, null);
|
||||
|
||||
@@ -40,7 +38,7 @@ public class ModifierSettingsManager {
|
||||
// throw new IllegalArgumentException("Player does not have modifierCapability capability");
|
||||
}
|
||||
|
||||
public static void setModifierSettings(EntityPlayer player, ModifierSettings modifierSettings) {
|
||||
public static void setModifierSettings(PlayerEntity player, ModifierSettings modifierSettings) {
|
||||
if (player == null) {
|
||||
EffortlessBuilding.log("Cannot set buildsettings, player is null");
|
||||
return;
|
||||
@@ -58,7 +56,7 @@ public class ModifierSettingsManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static String sanitize(ModifierSettings modifierSettings, EntityPlayer player) {
|
||||
public static String sanitize(ModifierSettings modifierSettings, PlayerEntity player) {
|
||||
int maxReach = ReachHelper.getMaxReach(player);
|
||||
String error = "";
|
||||
|
||||
@@ -194,7 +192,7 @@ public class ModifierSettingsManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static void handleNewPlayer(EntityPlayer player){
|
||||
public static void handleNewPlayer(PlayerEntity player){
|
||||
//Makes sure player has modifier settings (if it doesnt it will create it)
|
||||
getModifierSettings(player);
|
||||
|
||||
@@ -202,7 +200,7 @@ public class ModifierSettingsManager {
|
||||
if (!player.world.isRemote) {
|
||||
//Send to client
|
||||
ModifierSettingsMessage msg = new ModifierSettingsMessage(getModifierSettings(player));
|
||||
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (EntityPlayerMP) player), msg);
|
||||
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package nl.requios.effortlessbuilding.buildmodifier;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Mirror;
|
||||
import net.minecraft.util.Rotation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -44,7 +44,7 @@ public class RadialMirror {
|
||||
}
|
||||
}
|
||||
|
||||
public static List<BlockPos> findCoordinates(EntityPlayer player, BlockPos startPos) {
|
||||
public static List<BlockPos> findCoordinates(PlayerEntity player, BlockPos startPos) {
|
||||
List<BlockPos> coordinates = new ArrayList<>();
|
||||
|
||||
//find radial mirror settings for the player
|
||||
@@ -77,8 +77,8 @@ public class RadialMirror {
|
||||
return coordinates;
|
||||
}
|
||||
|
||||
public static List<IBlockState> findBlockStates(EntityPlayer player, BlockPos startPos, IBlockState blockState, ItemStack itemStack, List<ItemStack> itemStacks) {
|
||||
List<IBlockState> blockStates = new ArrayList<>();
|
||||
public static List<BlockState> findBlockStates(PlayerEntity player, BlockPos startPos, BlockState blockState, ItemStack itemStack, List<ItemStack> itemStacks) {
|
||||
List<BlockState> blockStates = new ArrayList<>();
|
||||
List<BlockPos> coordinates = new ArrayList<>(); //to keep track of duplicates
|
||||
|
||||
//find radial mirror settings for the player that placed the block
|
||||
@@ -105,7 +105,7 @@ public class RadialMirror {
|
||||
bagInventory = ItemRandomizerBag.getBagInventory(itemStack);
|
||||
}
|
||||
|
||||
IBlockState newBlockState;
|
||||
BlockState newBlockState;
|
||||
for (int i = 1; i < r.slices; i++) {
|
||||
newBlockState = blockState;
|
||||
double curAngle = sliceAngle * i;
|
||||
@@ -124,7 +124,7 @@ public class RadialMirror {
|
||||
if (bagInventory != null) {
|
||||
itemStack = ItemRandomizerBag.pickRandomStack(bagInventory);
|
||||
newBlockState = BuildModifiers
|
||||
.getBlockStateFromItem(itemStack, player, startPos, EnumFacing.UP, new Vec3d(0, 0, 0), EnumHand.MAIN_HAND);
|
||||
.getBlockStateFromItem(itemStack, player, startPos, Direction.UP, new Vec3d(0, 0, 0), Hand.MAIN_HAND);
|
||||
|
||||
newBlockState = rotateOriginalBlockState(startAngleToCenter, newBlockState);
|
||||
}
|
||||
@@ -139,8 +139,8 @@ public class RadialMirror {
|
||||
return blockStates;
|
||||
}
|
||||
|
||||
private static IBlockState rotateOriginalBlockState(double startAngleToCenter, IBlockState blockState) {
|
||||
IBlockState newBlockState = blockState;
|
||||
private static BlockState rotateOriginalBlockState(double startAngleToCenter, BlockState blockState) {
|
||||
BlockState newBlockState = blockState;
|
||||
|
||||
if (startAngleToCenter < -0.751 * Math.PI || startAngleToCenter > 0.749 * Math.PI) {
|
||||
newBlockState = blockState.rotate(Rotation.CLOCKWISE_180);
|
||||
@@ -153,8 +153,8 @@ public class RadialMirror {
|
||||
return newBlockState;
|
||||
}
|
||||
|
||||
private static IBlockState rotateBlockState(Vec3d relVec, IBlockState blockState, boolean alternate) {
|
||||
IBlockState newBlockState;
|
||||
private static BlockState rotateBlockState(Vec3d relVec, BlockState blockState, boolean alternate) {
|
||||
BlockState newBlockState;
|
||||
double angleToCenter = MathHelper.atan2(relVec.x, relVec.z); //between -PI and PI
|
||||
|
||||
if (angleToCenter < -0.751 * Math.PI || angleToCenter > 0.749 * Math.PI) {
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
package nl.requios.effortlessbuilding.buildmodifier;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraft.world.storage.loot.LootContext;
|
||||
import net.minecraft.world.storage.loot.LootParameterSet;
|
||||
import nl.requios.effortlessbuilding.BuildConfig;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
import nl.requios.effortlessbuilding.helper.FixedStack;
|
||||
@@ -29,7 +32,7 @@ public class UndoRedo {
|
||||
private static Map<UUID, FixedStack<BlockSet>> redoStacksServer = new HashMap<>();
|
||||
|
||||
//add to undo stack
|
||||
public static void addUndo(EntityPlayer player, BlockSet blockSet) {
|
||||
public static void addUndo(PlayerEntity player, BlockSet blockSet) {
|
||||
Map<UUID, FixedStack<BlockSet>> undoStacks = player.world.isRemote ? undoStacksClient : undoStacksServer;
|
||||
|
||||
//Assert coordinates is as long as previous and new blockstate lists
|
||||
@@ -56,7 +59,7 @@ public class UndoRedo {
|
||||
undoStacks.get(player.getUniqueID()).push(blockSet);
|
||||
}
|
||||
|
||||
private static void addRedo(EntityPlayer player, BlockSet blockSet) {
|
||||
private static void addRedo(PlayerEntity player, BlockSet blockSet) {
|
||||
Map<UUID, FixedStack<BlockSet>> redoStacks = player.world.isRemote ? redoStacksClient : redoStacksServer;
|
||||
|
||||
//(No asserts necessary, it's private)
|
||||
@@ -69,7 +72,7 @@ public class UndoRedo {
|
||||
redoStacks.get(player.getUniqueID()).push(blockSet);
|
||||
}
|
||||
|
||||
public static boolean undo(EntityPlayer player) {
|
||||
public static boolean undo(PlayerEntity player) {
|
||||
Map<UUID, FixedStack<BlockSet>> undoStacks = player.world.isRemote ? undoStacksClient : undoStacksServer;
|
||||
|
||||
if (!undoStacks.containsKey(player.getUniqueID())) return false;
|
||||
@@ -80,8 +83,8 @@ public class UndoRedo {
|
||||
|
||||
BlockSet blockSet = undoStack.pop();
|
||||
List<BlockPos> coordinates = blockSet.getCoordinates();
|
||||
List<IBlockState> previousBlockStates = blockSet.getPreviousBlockStates();
|
||||
List<IBlockState> newBlockStates = blockSet.getNewBlockStates();
|
||||
List<BlockState> previousBlockStates = blockSet.getPreviousBlockStates();
|
||||
List<BlockState> newBlockStates = blockSet.getNewBlockStates();
|
||||
Vec3d hitVec = blockSet.getHitVec();
|
||||
|
||||
//Find up to date itemstacks in player inventory
|
||||
@@ -98,25 +101,27 @@ public class UndoRedo {
|
||||
if (previousBlockStates.get(i).equals(newBlockStates.get(i))) continue;
|
||||
|
||||
//get blockstate from itemstack
|
||||
IBlockState previousBlockState = Blocks.AIR.getDefaultState();
|
||||
if (itemStack.getItem() instanceof ItemBlock) {
|
||||
previousBlockState = previousBlockStates.get(i);//((ItemBlock) itemStack.getItem()).getBlock().getDefaultState();
|
||||
BlockState previousBlockState = Blocks.AIR.getDefaultState();
|
||||
if (itemStack.getItem() instanceof BlockItem) {
|
||||
previousBlockState = ((BlockItem) itemStack.getItem()).getBlock().getDefaultState();
|
||||
}
|
||||
|
||||
if (player.world.isBlockLoaded(coordinate, true)) {
|
||||
if (player.world.isBlockPresent(coordinate)) {
|
||||
//check itemstack empty
|
||||
if (itemStack.isEmpty()) {
|
||||
itemStack = findItemStackInInventory(player, previousBlockStates.get(i));
|
||||
//get blockstate from new itemstack
|
||||
if (!itemStack.isEmpty() && itemStack.getItem() instanceof ItemBlock) {
|
||||
previousBlockState = previousBlockStates.get(i);//((ItemBlock) itemStack.getItem()).getBlock().getDefaultState();
|
||||
if (!itemStack.isEmpty() && itemStack.getItem() instanceof BlockItem) {
|
||||
previousBlockState = ((BlockItem) itemStack.getItem()).getBlock().getDefaultState();
|
||||
} else {
|
||||
if (previousBlockStates.get(i).getBlock() != Blocks.AIR)
|
||||
EffortlessBuilding.logTranslate(player, "", previousBlockStates.get(i).getBlock().getTranslationKey(), " not found in inventory", true);
|
||||
previousBlockState = Blocks.AIR.getDefaultState();
|
||||
}
|
||||
}
|
||||
if (itemStack.isEmpty()) SurvivalHelper.breakBlock(player.world, player, coordinate, true);
|
||||
//if previousBlockState is air, placeBlock will set it to air
|
||||
SurvivalHelper.placeBlock(player.world, player, coordinate, previousBlockState, itemStack, EnumFacing.UP, hitVec, true, false, false);
|
||||
SurvivalHelper.placeBlock(player.world, player, coordinate, previousBlockState, itemStack, Direction.UP, hitVec, true, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -127,7 +132,7 @@ public class UndoRedo {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean redo(EntityPlayer player) {
|
||||
public static boolean redo(PlayerEntity player) {
|
||||
Map<UUID, FixedStack<BlockSet>> redoStacks = player.world.isRemote ? redoStacksClient : redoStacksServer;
|
||||
|
||||
if (!redoStacks.containsKey(player.getUniqueID())) return false;
|
||||
@@ -138,8 +143,8 @@ public class UndoRedo {
|
||||
|
||||
BlockSet blockSet = redoStack.pop();
|
||||
List<BlockPos> coordinates = blockSet.getCoordinates();
|
||||
List<IBlockState> previousBlockStates = blockSet.getPreviousBlockStates();
|
||||
List<IBlockState> newBlockStates = blockSet.getNewBlockStates();
|
||||
List<BlockState> previousBlockStates = blockSet.getPreviousBlockStates();
|
||||
List<BlockState> newBlockStates = blockSet.getNewBlockStates();
|
||||
Vec3d hitVec = blockSet.getHitVec();
|
||||
|
||||
//Find up to date itemstacks in player inventory
|
||||
@@ -156,24 +161,26 @@ public class UndoRedo {
|
||||
if (previousBlockStates.get(i).equals(newBlockStates.get(i))) continue;
|
||||
|
||||
//get blockstate from itemstack
|
||||
IBlockState newBlockState = Blocks.AIR.getDefaultState();
|
||||
if (itemStack.getItem() instanceof ItemBlock) {
|
||||
newBlockState = newBlockStates.get(i);//((ItemBlock) itemStack.getItem()).getBlock().getDefaultState();
|
||||
BlockState newBlockState = Blocks.AIR.getDefaultState();
|
||||
if (itemStack.getItem() instanceof BlockItem) {
|
||||
newBlockState = ((BlockItem) itemStack.getItem()).getBlock().getDefaultState();
|
||||
}
|
||||
|
||||
if (player.world.isBlockLoaded(coordinate, true)) {
|
||||
if (player.world.isBlockPresent(coordinate)) {
|
||||
//check itemstack empty
|
||||
if (itemStack.isEmpty()) {
|
||||
itemStack = findItemStackInInventory(player, newBlockStates.get(i));
|
||||
//get blockstate from new itemstack
|
||||
if (!itemStack.isEmpty() && itemStack.getItem() instanceof ItemBlock) {
|
||||
newBlockState = newBlockStates.get(i);//((ItemBlock) itemStack.getItem()).getBlock().getDefaultState();
|
||||
if (!itemStack.isEmpty() && itemStack.getItem() instanceof BlockItem) {
|
||||
newBlockState = ((BlockItem) itemStack.getItem()).getBlock().getDefaultState();
|
||||
} else {
|
||||
if (newBlockStates.get(i).getBlock() != Blocks.AIR)
|
||||
EffortlessBuilding.logTranslate(player, "", newBlockStates.get(i).getBlock().getTranslationKey(), " not found in inventory", true);
|
||||
newBlockState = Blocks.AIR.getDefaultState();
|
||||
}
|
||||
}
|
||||
if (itemStack.isEmpty()) SurvivalHelper.breakBlock(player.world, player, coordinate, true);
|
||||
SurvivalHelper.placeBlock(player.world, player, coordinate, newBlockState, itemStack, EnumFacing.UP, hitVec, true, false, false);
|
||||
SurvivalHelper.placeBlock(player.world, player, coordinate, newBlockState, itemStack, Direction.UP, hitVec, true, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -184,7 +191,7 @@ public class UndoRedo {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void clear(EntityPlayer player) {
|
||||
public static void clear(PlayerEntity player) {
|
||||
Map<UUID, FixedStack<BlockSet>> undoStacks = player.world.isRemote ? undoStacksClient : undoStacksServer;
|
||||
Map<UUID, FixedStack<BlockSet>> redoStacks = player.world.isRemote ? redoStacksClient : redoStacksServer;
|
||||
if (undoStacks.containsKey(player.getUniqueID())) {
|
||||
@@ -195,15 +202,15 @@ public class UndoRedo {
|
||||
}
|
||||
}
|
||||
|
||||
private static List<ItemStack> findItemStacksInInventory(EntityPlayer player, List<IBlockState> blockStates) {
|
||||
private static List<ItemStack> findItemStacksInInventory(PlayerEntity player, List<BlockState> blockStates) {
|
||||
List<ItemStack> itemStacks = new ArrayList<>(blockStates.size());
|
||||
for (IBlockState blockState : blockStates) {
|
||||
for (BlockState blockState : blockStates) {
|
||||
itemStacks.add(findItemStackInInventory(player, blockState));
|
||||
}
|
||||
return itemStacks;
|
||||
}
|
||||
|
||||
private static ItemStack findItemStackInInventory(EntityPlayer player, IBlockState blockState) {
|
||||
private static ItemStack findItemStackInInventory(PlayerEntity player, BlockState blockState) {
|
||||
ItemStack itemStack = ItemStack.EMPTY;
|
||||
if (blockState == null) return itemStack;
|
||||
|
||||
@@ -212,12 +219,19 @@ public class UndoRedo {
|
||||
// then change line 103 back (get state from item)
|
||||
itemStack = InventoryHelper.findItemStackInInventory(player, blockState.getBlock());
|
||||
|
||||
|
||||
//then anything it drops
|
||||
if (itemStack.isEmpty()) {
|
||||
Item itemDropped = blockState.getBlock().getItemDropped(blockState, player.world, BlockPos.ORIGIN, 10).asItem();
|
||||
if (itemDropped instanceof ItemBlock) {
|
||||
Block block = ((ItemBlock) itemDropped).getBlock();
|
||||
itemStack = InventoryHelper.findItemStackInInventory(player, block);
|
||||
//Cannot check drops on clientside because loot tables are server only
|
||||
if (!player.world.isRemote)
|
||||
{
|
||||
List<ItemStack> itemsDropped = Block.getDrops(blockState, (ServerWorld) player.world, BlockPos.ZERO, null);
|
||||
for (ItemStack itemStackDropped : itemsDropped) {
|
||||
if (itemStackDropped.getItem() instanceof BlockItem) {
|
||||
Block block = ((BlockItem) itemStackDropped.getItem()).getBlock();
|
||||
itemStack = InventoryHelper.findItemStackInInventory(player, block);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package nl.requios.effortlessbuilding.capability;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.CapabilityInject;
|
||||
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
@@ -14,22 +13,22 @@ import nl.requios.effortlessbuilding.item.ItemRandomizerBag;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ItemHandlerCapabilityProvider implements ICapabilitySerializable<NBTTagCompound> {
|
||||
public class ItemHandlerCapabilityProvider implements ICapabilitySerializable<CompoundNBT> {
|
||||
IItemHandler itemHandler = new ItemStackHandler(ItemRandomizerBag.INV_SIZE);
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable EnumFacing side) {
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
|
||||
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.orEmpty(cap, LazyOptional.of(() -> itemHandler));
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound serializeNBT() {
|
||||
public CompoundNBT serializeNBT() {
|
||||
return ((ItemStackHandler) itemHandler).serializeNBT();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserializeNBT(NBTTagCompound nbt) {
|
||||
public void deserializeNBT(CompoundNBT nbt) {
|
||||
((ItemStackHandler) itemHandler).deserializeNBT(nbt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package nl.requios.effortlessbuilding.capability;
|
||||
|
||||
import net.minecraft.nbt.INBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.INBT;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.CapabilityInject;
|
||||
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
|
||||
@@ -45,12 +45,12 @@ public class ModeCapabilityManager {
|
||||
|
||||
public static class Storage implements Capability.IStorage<IModeCapability> {
|
||||
@Override
|
||||
public INBTBase writeNBT(Capability<IModeCapability> capability, IModeCapability instance, EnumFacing side) {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
public INBT writeNBT(Capability<IModeCapability> capability, IModeCapability instance, Direction side) {
|
||||
CompoundNBT compound = new CompoundNBT();
|
||||
ModeSettings modeSettings = instance.getModeData();
|
||||
if (modeSettings == null) modeSettings = new ModeSettings();
|
||||
|
||||
//compound.setInteger("buildMode", modeSettings.getBuildMode().ordinal());
|
||||
//compound.putInteger("buildMode", modeSettings.getBuildMode().ordinal());
|
||||
|
||||
//TODO add mode settings
|
||||
|
||||
@@ -58,8 +58,8 @@ public class ModeCapabilityManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readNBT(Capability<IModeCapability> capability, IModeCapability instance, EnumFacing side, INBTBase nbt) {
|
||||
NBTTagCompound compound = (NBTTagCompound) nbt;
|
||||
public void readNBT(Capability<IModeCapability> capability, IModeCapability instance, Direction side, INBT nbt) {
|
||||
CompoundNBT compound = (CompoundNBT) nbt;
|
||||
|
||||
//BuildModes.BuildModeEnum buildMode = BuildModes.BuildModeEnum.values()[compound.getInteger("buildMode")];
|
||||
|
||||
@@ -70,22 +70,22 @@ public class ModeCapabilityManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static class Provider implements ICapabilitySerializable<INBTBase> {
|
||||
public static class Provider implements ICapabilitySerializable<INBT> {
|
||||
IModeCapability inst = modeCapability.getDefaultInstance();
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable EnumFacing side) {
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
|
||||
return modeCapability.orEmpty(cap, LazyOptional.of(() -> inst));
|
||||
}
|
||||
|
||||
@Override
|
||||
public INBTBase serializeNBT() {
|
||||
public INBT serializeNBT() {
|
||||
return modeCapability.getStorage().writeNBT(modeCapability, inst, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserializeNBT(INBTBase nbt) {
|
||||
public void deserializeNBT(INBT nbt) {
|
||||
modeCapability.getStorage().readNBT(modeCapability, inst, null, nbt);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package nl.requios.effortlessbuilding.capability;
|
||||
|
||||
import net.minecraft.nbt.INBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.INBT;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
@@ -12,7 +12,6 @@ import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.Array;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.Mirror;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.RadialMirror;
|
||||
@@ -20,8 +19,6 @@ import nl.requios.effortlessbuilding.buildmodifier.RadialMirror;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import static nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager.*;
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
@@ -52,57 +49,57 @@ public class ModifierCapabilityManager {
|
||||
|
||||
public static class Storage implements Capability.IStorage<IModifierCapability> {
|
||||
@Override
|
||||
public INBTBase writeNBT(Capability<IModifierCapability> capability, IModifierCapability instance, EnumFacing side) {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
public INBT writeNBT(Capability<IModifierCapability> capability, IModifierCapability instance, Direction side) {
|
||||
CompoundNBT compound = new CompoundNBT();
|
||||
ModifierSettings modifierSettings = instance.getModifierData();
|
||||
if (modifierSettings == null) modifierSettings = new ModifierSettings();
|
||||
|
||||
//MIRROR
|
||||
Mirror.MirrorSettings m = modifierSettings.getMirrorSettings();
|
||||
if (m == null) m = new Mirror.MirrorSettings();
|
||||
compound.setBoolean("mirrorEnabled", m.enabled);
|
||||
compound.setDouble("mirrorPosX", m.position.x);
|
||||
compound.setDouble("mirrorPosY", m.position.y);
|
||||
compound.setDouble("mirrorPosZ", m.position.z);
|
||||
compound.setBoolean("mirrorX", m.mirrorX);
|
||||
compound.setBoolean("mirrorY", m.mirrorY);
|
||||
compound.setBoolean("mirrorZ", m.mirrorZ);
|
||||
compound.setInt("mirrorRadius", m.radius);
|
||||
compound.setBoolean("mirrorDrawLines", m.drawLines);
|
||||
compound.setBoolean("mirrorDrawPlanes", m.drawPlanes);
|
||||
compound.putBoolean("mirrorEnabled", m.enabled);
|
||||
compound.putDouble("mirrorPosX", m.position.x);
|
||||
compound.putDouble("mirrorPosY", m.position.y);
|
||||
compound.putDouble("mirrorPosZ", m.position.z);
|
||||
compound.putBoolean("mirrorX", m.mirrorX);
|
||||
compound.putBoolean("mirrorY", m.mirrorY);
|
||||
compound.putBoolean("mirrorZ", m.mirrorZ);
|
||||
compound.putInt("mirrorRadius", m.radius);
|
||||
compound.putBoolean("mirrorDrawLines", m.drawLines);
|
||||
compound.putBoolean("mirrorDrawPlanes", m.drawPlanes);
|
||||
|
||||
//ARRAY
|
||||
Array.ArraySettings a = modifierSettings.getArraySettings();
|
||||
if (a == null) a = new Array.ArraySettings();
|
||||
compound.setBoolean("arrayEnabled", a.enabled);
|
||||
compound.setInt("arrayOffsetX", a.offset.getX());
|
||||
compound.setInt("arrayOffsetY", a.offset.getY());
|
||||
compound.setInt("arrayOffsetZ", a.offset.getZ());
|
||||
compound.setInt("arrayCount", a.count);
|
||||
compound.putBoolean("arrayEnabled", a.enabled);
|
||||
compound.putInt("arrayOffsetX", a.offset.getX());
|
||||
compound.putInt("arrayOffsetY", a.offset.getY());
|
||||
compound.putInt("arrayOffsetZ", a.offset.getZ());
|
||||
compound.putInt("arrayCount", a.count);
|
||||
|
||||
compound.setInt("reachUpgrade", modifierSettings.getReachUpgrade());
|
||||
compound.putInt("reachUpgrade", modifierSettings.getReachUpgrade());
|
||||
|
||||
//compound.setBoolean("quickReplace", buildSettings.doQuickReplace()); dont save quickreplace
|
||||
//compound.putBoolean("quickReplace", buildSettings.doQuickReplace()); dont save quickreplace
|
||||
|
||||
//RADIAL MIRROR
|
||||
RadialMirror.RadialMirrorSettings r = modifierSettings.getRadialMirrorSettings();
|
||||
if (r == null) r = new RadialMirror.RadialMirrorSettings();
|
||||
compound.setBoolean("radialMirrorEnabled", r.enabled);
|
||||
compound.setDouble("radialMirrorPosX", r.position.x);
|
||||
compound.setDouble("radialMirrorPosY", r.position.y);
|
||||
compound.setDouble("radialMirrorPosZ", r.position.z);
|
||||
compound.setInt("radialMirrorSlices", r.slices);
|
||||
compound.setBoolean("radialMirrorAlternate", r.alternate);
|
||||
compound.setInt("radialMirrorRadius", r.radius);
|
||||
compound.setBoolean("radialMirrorDrawLines", r.drawLines);
|
||||
compound.setBoolean("radialMirrorDrawPlanes", r.drawPlanes);
|
||||
compound.putBoolean("radialMirrorEnabled", r.enabled);
|
||||
compound.putDouble("radialMirrorPosX", r.position.x);
|
||||
compound.putDouble("radialMirrorPosY", r.position.y);
|
||||
compound.putDouble("radialMirrorPosZ", r.position.z);
|
||||
compound.putInt("radialMirrorSlices", r.slices);
|
||||
compound.putBoolean("radialMirrorAlternate", r.alternate);
|
||||
compound.putInt("radialMirrorRadius", r.radius);
|
||||
compound.putBoolean("radialMirrorDrawLines", r.drawLines);
|
||||
compound.putBoolean("radialMirrorDrawPlanes", r.drawPlanes);
|
||||
|
||||
return compound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readNBT(Capability<IModifierCapability> capability, IModifierCapability instance, EnumFacing side, INBTBase nbt) {
|
||||
NBTTagCompound compound = (NBTTagCompound) nbt;
|
||||
public void readNBT(Capability<IModifierCapability> capability, IModifierCapability instance, Direction side, INBT nbt) {
|
||||
CompoundNBT compound = (CompoundNBT) nbt;
|
||||
|
||||
//MIRROR
|
||||
boolean mirrorEnabled = compound.getBoolean("mirrorEnabled");
|
||||
@@ -150,23 +147,23 @@ public class ModifierCapabilityManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static class Provider implements ICapabilitySerializable<INBTBase> {
|
||||
public static class Provider implements ICapabilitySerializable<INBT> {
|
||||
|
||||
IModifierCapability inst = modifierCapability.getDefaultInstance();
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable EnumFacing side) {
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
|
||||
return modifierCapability.orEmpty(cap, LazyOptional.of(() -> inst));
|
||||
}
|
||||
|
||||
@Override
|
||||
public INBTBase serializeNBT() {
|
||||
public INBT serializeNBT() {
|
||||
return modifierCapability.getStorage().writeNBT(modifierCapability, inst, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserializeNBT(INBTBase nbt) {
|
||||
public void deserializeNBT(INBT nbt) {
|
||||
modifierCapability.getStorage().readNBT(modifierCapability, inst, null, nbt);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,14 +4,13 @@ import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.command.Commands;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraftforge.fml.network.PacketDistributor;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
|
||||
import nl.requios.effortlessbuilding.network.ModifierSettingsMessage;
|
||||
import nl.requios.effortlessbuilding.network.PacketHandler;
|
||||
import nl.requios.effortlessbuilding.network.RequestLookAtMessage;
|
||||
|
||||
public class CommandReach {
|
||||
|
||||
@@ -23,19 +22,19 @@ public class CommandReach {
|
||||
}))));
|
||||
}
|
||||
|
||||
private static int setReachLevel(EntityPlayerMP player, int level){
|
||||
private static int setReachLevel(ServerPlayerEntity player, int level){
|
||||
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
|
||||
modifierSettings.setReachUpgrade(level);
|
||||
ModifierSettingsManager.setModifierSettings(player, modifierSettings);
|
||||
//Send to client
|
||||
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> player), new ModifierSettingsMessage(modifierSettings));
|
||||
|
||||
player.sendMessage(new TextComponentString("Reach level of " + player.getName().getString() + " set to " + modifierSettings.getReachUpgrade()));
|
||||
player.sendMessage(new StringTextComponent("Reach level of " + player.getName().getString() + " set to " + modifierSettings.getReachUpgrade()));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int getReachLevel(EntityPlayerMP player){
|
||||
private static int getReachLevel(ServerPlayerEntity player){
|
||||
int reachUpgrade = ModifierSettingsManager.getModifierSettings(player).getReachUpgrade();
|
||||
EffortlessBuilding.log(player, "Current reach: level "+reachUpgrade);
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package nl.requios.effortlessbuilding.compatibility;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
@@ -39,7 +38,7 @@ public class CompatHelper {
|
||||
// /dank/null, or plain old blocks.
|
||||
public static boolean isItemBlockProxy(ItemStack stack) {
|
||||
Item item = stack.getItem();
|
||||
if (item instanceof ItemBlock)
|
||||
if (item instanceof BlockItem)
|
||||
return true;
|
||||
if ((item instanceof ItemRandomizerBag))
|
||||
return true;
|
||||
@@ -54,13 +53,13 @@ public class CompatHelper {
|
||||
public static ItemStack getItemBlockFromStack(ItemStack proxy) {
|
||||
Item proxyItem = proxy.getItem();
|
||||
|
||||
if (proxyItem instanceof ItemBlock)
|
||||
if (proxyItem instanceof BlockItem)
|
||||
return proxy;
|
||||
|
||||
//Randomizer Bag
|
||||
if (proxyItem instanceof ItemRandomizerBag) {
|
||||
ItemStack itemStack = proxy;
|
||||
while (!(itemStack.getItem() instanceof ItemBlock || itemStack.isEmpty())) {
|
||||
while (!(itemStack.getItem() instanceof BlockItem || itemStack.isEmpty())) {
|
||||
if (itemStack.getItem() instanceof ItemRandomizerBag)
|
||||
itemStack = ItemRandomizerBag.pickRandomStack(ItemRandomizerBag.getBagInventory(itemStack));
|
||||
}
|
||||
@@ -79,11 +78,11 @@ public class CompatHelper {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
public static ItemStack getItemBlockByState(ItemStack stack, IBlockState state) {
|
||||
public static ItemStack getItemBlockByState(ItemStack stack, BlockState state) {
|
||||
if (state == null) return ItemStack.EMPTY;
|
||||
|
||||
Item blockItem = Item.getItemFromBlock(state.getBlock());
|
||||
if (stack.getItem() instanceof ItemBlock)
|
||||
if (stack.getItem() instanceof BlockItem)
|
||||
return stack;
|
||||
else if (stack.getItem() instanceof ItemRandomizerBag) {
|
||||
IItemHandler bagInventory = ItemRandomizerBag.getBagInventory(stack);
|
||||
@@ -100,7 +99,7 @@ public class CompatHelper {
|
||||
|
||||
// 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, EntityPlayer player) {
|
||||
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);
|
||||
@@ -123,7 +122,7 @@ public class CompatHelper {
|
||||
|
||||
for (int i = 0; i < handler.getSlots(); i++) {
|
||||
ItemStack ref = handler.getStackInSlot(i);
|
||||
if (ref.getItem() instanceof ItemBlock)
|
||||
if (ref.getItem() instanceof BlockItem)
|
||||
if (ref.getItem() == blockItem)
|
||||
return i;
|
||||
}
|
||||
|
||||
@@ -1,28 +1,36 @@
|
||||
package nl.requios.effortlessbuilding.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ClickType;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.inventory.container.ClickType;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumHand;
|
||||
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.ItemRandomizerBag;
|
||||
|
||||
public class RandomizerBagContainer extends Container {
|
||||
|
||||
private final IItemHandler bagInventory;
|
||||
private final int sizeInventory;
|
||||
|
||||
private static final int INV_START = ItemRandomizerBag.INV_SIZE, INV_END = INV_START + 26,
|
||||
HOTBAR_START = INV_END + 1, HOTBAR_END = HOTBAR_START + 8;
|
||||
|
||||
public RandomizerBagContainer(InventoryPlayer parInventoryPlayer, IItemHandler parIInventory) {
|
||||
bagInventory = parIInventory;
|
||||
sizeInventory = bagInventory.getSlots();
|
||||
for (int i = 0; i < sizeInventory; ++i) {
|
||||
public RandomizerBagContainer(int containerId, PlayerInventory playerInventory) {
|
||||
this(containerId, playerInventory, new ItemStackHandler(ItemRandomizerBag.INV_SIZE));
|
||||
}
|
||||
|
||||
public RandomizerBagContainer(int containerId, PlayerInventory playerInventory, IItemHandler inventory) {
|
||||
super(EffortlessBuilding.RANDOMIZER_BAG_CONTAINER, containerId);
|
||||
bagInventory = inventory;
|
||||
|
||||
for (int i = 0; i < ItemRandomizerBag.INV_SIZE; ++i) {
|
||||
this.addSlot(new SlotItemHandler(bagInventory, i, 44 + (18 * i), 20));
|
||||
}
|
||||
|
||||
@@ -30,18 +38,18 @@ public class RandomizerBagContainer extends Container {
|
||||
int i;
|
||||
for (i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
addSlot(new Slot(parInventoryPlayer, 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
|
||||
for (i = 0; i < 9; ++i) {
|
||||
addSlot(new Slot(parInventoryPlayer, i, 8 + i * 18, 109));
|
||||
addSlot(new Slot(playerInventory, i, 8 + i * 18, 109));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer playerIn) {
|
||||
public boolean canInteractWith(PlayerEntity playerIn) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -54,7 +62,7 @@ public class RandomizerBagContainer extends Container {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer playerIn, int slotIndex) {
|
||||
public ItemStack transferStackInSlot(PlayerEntity playerIn, int slotIndex) {
|
||||
ItemStack itemstack = ItemStack.EMPTY;
|
||||
Slot slot = this.inventorySlots.get(slotIndex);
|
||||
|
||||
@@ -107,9 +115,9 @@ public class RandomizerBagContainer extends Container {
|
||||
* be able to save properly
|
||||
*/
|
||||
@Override
|
||||
public ItemStack slotClick(int slot, int dragType, ClickType clickTypeIn, EntityPlayer player) {
|
||||
public ItemStack slotClick(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).getStack().equals(player.getHeldItem(EnumHand.MAIN_HAND))) {
|
||||
if (slot >= 0 && getSlot(slot) != null && getSlot(slot).getStack().equals(player.getHeldItem(Hand.MAIN_HAND))) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
return super.slotClick(slot, dragType, clickTypeIn, player);
|
||||
@@ -119,7 +127,7 @@ public class RandomizerBagContainer extends Container {
|
||||
* Callback for when the crafting gui is closed.
|
||||
*/
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer player)
|
||||
public void onContainerClosed(PlayerEntity player)
|
||||
{
|
||||
super.onContainerClosed(player);
|
||||
if(!player.world.isRemote)
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
package nl.requios.effortlessbuilding.gui;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.world.IInteractionObject;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fml.common.network.IGuiHandler;
|
||||
import net.minecraftforge.fml.network.FMLPlayMessages;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
import nl.requios.effortlessbuilding.capability.ItemHandlerCapabilityProvider;
|
||||
import nl.requios.effortlessbuilding.item.ItemRandomizerBag;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class RandomizerBagGuiHandler implements /*IGuiHandler, */IInteractionObject {
|
||||
// @Nullable
|
||||
// @Override
|
||||
// public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
// if (ID == EffortlessBuilding.RANDOMIZER_BAG_GUI) {
|
||||
// // Use the player's held item to create the container
|
||||
// LazyOptional<IItemHandler> capabilityOptional = player.getHeldItemMainhand().getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
|
||||
//
|
||||
// if (!capabilityOptional.isPresent()) {
|
||||
// capabilityOptional = player.getHeldItemOffhand().getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
|
||||
// }
|
||||
//
|
||||
// return new RandomizerBagContainer(player.inventory, capabilityOptional.orElse(null));
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// @Nullable
|
||||
// @Override
|
||||
// @OnlyIn(Dist.CLIENT)
|
||||
// public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
// if (ID == EffortlessBuilding.RANDOMIZER_BAG_GUI) {
|
||||
// // Use the player's held item to create the client-side gui container
|
||||
// LazyOptional<IItemHandler> capabilityOptional = player.getHeldItemMainhand().getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
|
||||
//
|
||||
// if (!capabilityOptional.isPresent()) {
|
||||
// capabilityOptional = player.getHeldItemOffhand().getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
|
||||
// }
|
||||
//
|
||||
// return new RandomizerBagGuiContainer(player.inventory, capabilityOptional.orElse(null));
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static GuiScreen openGui(FMLPlayMessages.OpenContainer openContainer) {
|
||||
if (openContainer.getId().equals(EffortlessBuilding.RANDOMIZER_BAG_GUI)) {
|
||||
EntityPlayerSP player = Minecraft.getInstance().player;
|
||||
if (player.getHeldItem(EnumHand.MAIN_HAND).getItem() instanceof ItemRandomizerBag) {
|
||||
IItemHandler itemHandler = player.getHeldItem(EnumHand.MAIN_HAND).getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElse(null);
|
||||
if (itemHandler != null) {
|
||||
return new RandomizerBagGuiContainer(player.inventory, itemHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container createContainer(InventoryPlayer inventory, EntityPlayer player) {
|
||||
if (player.getHeldItem(EnumHand.MAIN_HAND).getItem() instanceof ItemRandomizerBag) {
|
||||
IItemHandler itemHandler = player.getHeldItem(EnumHand.MAIN_HAND).getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElse(null);
|
||||
if (itemHandler != null) {
|
||||
return new RandomizerBagContainer(inventory, itemHandler);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiID() {
|
||||
return EffortlessBuilding.RANDOMIZER_BAG_GUI.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextComponent getName() {
|
||||
return new TextComponentString("Randomizer Bag");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextComponent getDisplayName() {
|
||||
return new TextComponentString("Randomizer Bag");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ITextComponent getCustomName() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,49 +1,45 @@
|
||||
package nl.requios.effortlessbuilding.gui;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
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.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class RandomizerBagGuiContainer extends GuiContainer {
|
||||
public class RandomizerBagScreen extends ContainerScreen<RandomizerBagContainer> {
|
||||
private static final ResourceLocation guiTextures =
|
||||
new ResourceLocation(EffortlessBuilding.MODID, "textures/gui/container/randomizerbag.png");
|
||||
private final InventoryPlayer inventoryPlayer;
|
||||
private final IItemHandler inventoryBag;
|
||||
|
||||
public RandomizerBagGuiContainer(InventoryPlayer inventoryPlayer, IItemHandler inventoryBag) {
|
||||
super(new RandomizerBagContainer(inventoryPlayer, inventoryBag));
|
||||
this.inventoryPlayer = inventoryPlayer;
|
||||
this.inventoryBag = inventoryBag;
|
||||
|
||||
public RandomizerBagScreen(RandomizerBagContainer randomizerBagContainer, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(randomizerBagContainer, playerInventory, title);//new TranslationTextComponent("effortlessbuilding.screen.randomizer_bag"));
|
||||
ySize = 134;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||
drawDefaultBackground();
|
||||
renderBackground();
|
||||
super.render(mouseX, mouseY, partialTicks);
|
||||
this.renderHoveredToolTip(mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
String s = "Randomizer Bag";
|
||||
fontRenderer.drawString(s, 8, 6, 0x404040);
|
||||
fontRenderer.drawString(inventoryPlayer.getDisplayName().getUnformattedComponentText(), 8, ySize - 96 + 2, 0x404040);
|
||||
font.drawString(this.title.getFormattedText(), 8, 6, 0x404040);
|
||||
font.drawString(playerInventory.getDisplayName().getFormattedText(), 8, ySize - 96 + 2, 0x404040);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
|
||||
GlStateManager.color3f(1.0F, 1.0F, 1.0F);
|
||||
mc.getTextureManager().bindTexture(guiTextures);
|
||||
minecraft.getTextureManager().bindTexture(guiTextures);
|
||||
int marginHorizontal = (width - xSize) / 2;
|
||||
int marginVertical = (height - ySize) / 2;
|
||||
drawTexturedModalRect(marginHorizontal, marginVertical, 0, 0, xSize, ySize);
|
||||
blit(marginHorizontal, marginVertical, 0, 0, xSize, ySize);
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,16 @@ package nl.requios.effortlessbuilding.gui.buildmode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
||||
import nl.requios.effortlessbuilding.ModClientEventHandler;
|
||||
import nl.requios.effortlessbuilding.ModEventHandler;
|
||||
import nl.requios.effortlessbuilding.buildmode.ModeSettingsManager;
|
||||
import nl.requios.effortlessbuilding.proxy.ClientProxy;
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
@@ -16,14 +21,10 @@ import org.lwjgl.opengl.GL11;
|
||||
import com.google.common.base.Stopwatch;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
|
||||
import static nl.requios.effortlessbuilding.buildmode.BuildModes.*;
|
||||
import static nl.requios.effortlessbuilding.buildmode.ModeOptions.*;
|
||||
@@ -32,7 +33,7 @@ import static nl.requios.effortlessbuilding.buildmode.ModeOptions.*;
|
||||
* 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
|
||||
*/
|
||||
public class RadialMenu extends GuiScreen {
|
||||
public class RadialMenu extends Screen {
|
||||
|
||||
private final float TIME_SCALE = 0.01f;
|
||||
public static final RadialMenu instance = new RadialMenu();
|
||||
@@ -43,6 +44,10 @@ public class RadialMenu extends GuiScreen {
|
||||
public ActionEnum doAction = null;
|
||||
public boolean actionUsed = false;
|
||||
|
||||
public RadialMenu() {
|
||||
super(new TranslationTextComponent("effortlessbuilding.screen.radial_menu"));
|
||||
}
|
||||
|
||||
private float clampVis(final float f) {
|
||||
return Math.max( 0.0f, Math.min( 1.0f, f ) );
|
||||
}
|
||||
@@ -66,8 +71,8 @@ public class RadialMenu extends GuiScreen {
|
||||
}
|
||||
|
||||
public void configure(final int scaledWidth, final int scaledHeight ) {
|
||||
mc = Minecraft.getInstance();
|
||||
fontRenderer = mc.fontRenderer;
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
font = mc.fontRenderer;
|
||||
width = scaledWidth;
|
||||
height = scaledHeight;
|
||||
}
|
||||
@@ -80,10 +85,10 @@ public class RadialMenu extends GuiScreen {
|
||||
|
||||
public final ActionEnum action;
|
||||
public String name;
|
||||
public EnumFacing textSide;
|
||||
public Direction textSide;
|
||||
|
||||
public MenuButton(final String name, final ActionEnum action, final double x, final double y,
|
||||
final EnumFacing textSide) {
|
||||
final Direction textSide) {
|
||||
this.name = I18n.format(name);
|
||||
this.action = action;
|
||||
x1 = x - 10;
|
||||
@@ -120,9 +125,9 @@ public class RadialMenu extends GuiScreen {
|
||||
final int startColor = (int) ( visibility * 98 ) << 24;
|
||||
final int endColor = (int) ( visibility * 128 ) << 24;
|
||||
|
||||
drawGradientRect(0, 0, width, height, startColor, endColor);
|
||||
fillGradient(0, 0, width, height, startColor, endColor);
|
||||
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.disableTexture();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.disableAlphaTest();
|
||||
GlStateManager.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||
@@ -158,17 +163,17 @@ public class RadialMenu extends GuiScreen {
|
||||
}
|
||||
|
||||
//Add actions
|
||||
buttons.add(new MenuButton(ActionEnum.UNDO.name, ActionEnum.UNDO, -buttonDistance - 26, -13, EnumFacing.UP));
|
||||
buttons.add(new MenuButton(ActionEnum.REDO.name, ActionEnum.REDO, -buttonDistance, -13, EnumFacing.UP));
|
||||
buttons.add(new MenuButton(ActionEnum.OPEN_MODIFIER_SETTINGS.name, ActionEnum.OPEN_MODIFIER_SETTINGS, -buttonDistance - 26, 13, EnumFacing.DOWN));
|
||||
buttons.add(new MenuButton(ActionEnum.REPLACE.name, ActionEnum.REPLACE, -buttonDistance, 13, EnumFacing.DOWN));
|
||||
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.OPEN_MODIFIER_SETTINGS.name, ActionEnum.OPEN_MODIFIER_SETTINGS, -buttonDistance - 26, 13, Direction.DOWN));
|
||||
buttons.add(new MenuButton(ActionEnum.REPLACE.name, ActionEnum.REPLACE, -buttonDistance, 13, Direction.DOWN));
|
||||
|
||||
//Add buildmode dependent options
|
||||
OptionEnum[] options = currentBuildMode.options;
|
||||
for (int i = 0; i < options.length; i++) {
|
||||
for (int j = 0; j < options[i].actions.length; j++) {
|
||||
ActionEnum action = options[i].actions[j];
|
||||
buttons.add(new MenuButton(action.name, action, buttonDistance + j * 26, -13 + i * 39, EnumFacing.DOWN));
|
||||
buttons.add(new MenuButton(action.name, action, buttonDistance + j * 26, -13 + i * 39, Direction.DOWN));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,10 +236,10 @@ public class RadialMenu extends GuiScreen {
|
||||
switchTo = menuRegion.mode;
|
||||
}
|
||||
|
||||
buffer.pos(middleX + x1m1, middleY + y1m1, zLevel).color(r, g, b, a).endVertex();
|
||||
buffer.pos(middleX + x2m1, middleY + y2m1, zLevel).color(r, g, b, a).endVertex();
|
||||
buffer.pos(middleX + x2m2, middleY + y2m2, zLevel).color(r, g, b, a).endVertex();
|
||||
buffer.pos(middleX + x1m2, middleY + y1m2, zLevel).color(r, g, b, a).endVertex();
|
||||
buffer.pos(middleX + x1m1, middleY + y1m1, blitOffset).color(r, g, b, a).endVertex();
|
||||
buffer.pos(middleX + x2m1, middleY + y2m1, blitOffset).color(r, g, b, a).endVertex();
|
||||
buffer.pos(middleX + x2m2, middleY + y2m2, blitOffset).color(r, g, b, a).endVertex();
|
||||
buffer.pos(middleX + x1m2, middleY + y1m2, blitOffset).color(r, g, b, a).endVertex();
|
||||
|
||||
currentMode++;
|
||||
}
|
||||
@@ -270,10 +275,10 @@ public class RadialMenu extends GuiScreen {
|
||||
doAction = btn.action;
|
||||
}
|
||||
|
||||
buffer.pos(middleX + btn.x1, middleY + btn.y1, zLevel).color(r, g, b, a).endVertex();
|
||||
buffer.pos(middleX + btn.x1, middleY + btn.y2, zLevel).color(r, g, b, a).endVertex();
|
||||
buffer.pos(middleX + btn.x2, middleY + btn.y2, zLevel).color(r, g, b, a).endVertex();
|
||||
buffer.pos(middleX + btn.x2, middleY + btn.y1, zLevel).color(r, g, b, a).endVertex();
|
||||
buffer.pos(middleX + btn.x1, middleY + btn.y1, blitOffset).color(r, g, b, a).endVertex();
|
||||
buffer.pos(middleX + btn.x1, middleY + btn.y2, blitOffset).color(r, g, b, a).endVertex();
|
||||
buffer.pos(middleX + btn.x2, middleY + btn.y2, blitOffset).color(r, g, b, a).endVertex();
|
||||
buffer.pos(middleX + btn.x2, middleY + btn.y1, blitOffset).color(r, g, b, a).endVertex();
|
||||
}
|
||||
|
||||
tessellator.draw();
|
||||
@@ -281,7 +286,7 @@ public class RadialMenu extends GuiScreen {
|
||||
GlStateManager.shadeModel(GL11.GL_FLAT);
|
||||
|
||||
GlStateManager.translatef(0f, 0f, 5f);
|
||||
GlStateManager.enableTexture2D();
|
||||
GlStateManager.enableTexture();
|
||||
GlStateManager.color3f(1f, 1f, 1f);
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.enableAlphaTest();
|
||||
@@ -295,7 +300,7 @@ public class RadialMenu extends GuiScreen {
|
||||
final double x = (menuRegion.x1 + menuRegion.x2) * 0.5 * (ringOuterEdge * 0.6 + 0.4 * ringInnerEdge);
|
||||
final double y = (menuRegion.y1 + menuRegion.y2) * 0.5 * (ringOuterEdge * 0.6 + 0.4 * ringInnerEdge);
|
||||
|
||||
final TextureAtlasSprite sprite = ClientProxy.getBuildModeIcon(menuRegion.mode);
|
||||
final TextureAtlasSprite sprite = ModClientEventHandler.getBuildModeIcon(menuRegion.mode);
|
||||
|
||||
final double x1 = x - 8;
|
||||
final double x2 = x + 8;
|
||||
@@ -310,10 +315,10 @@ public class RadialMenu extends GuiScreen {
|
||||
final double v1 = 0;
|
||||
final double v2 = 16;
|
||||
|
||||
buffer.pos(middleX + x1, middleY + y1, zLevel).tex(sprite.getInterpolatedU(u1), sprite.getInterpolatedV(v1)).color(f, f, f, a).endVertex();
|
||||
buffer.pos(middleX + x1, middleY + y2, zLevel).tex(sprite.getInterpolatedU(u1), sprite.getInterpolatedV(v2)).color(f, f, f, a).endVertex();
|
||||
buffer.pos(middleX + x2, middleY + y2, zLevel).tex(sprite.getInterpolatedU(u2), sprite.getInterpolatedV(v2)).color(f, f, f, a).endVertex();
|
||||
buffer.pos(middleX + x2, middleY + y1, zLevel).tex(sprite.getInterpolatedU(u2), sprite.getInterpolatedV(v1)).color(f, f, f, a).endVertex();
|
||||
buffer.pos(middleX + x1, middleY + y1, blitOffset).tex(sprite.getInterpolatedU(u1), sprite.getInterpolatedV(v1)).color(f, f, f, a).endVertex();
|
||||
buffer.pos(middleX + x1, middleY + y2, blitOffset).tex(sprite.getInterpolatedU(u1), sprite.getInterpolatedV(v2)).color(f, f, f, a).endVertex();
|
||||
buffer.pos(middleX + x2, middleY + y2, blitOffset).tex(sprite.getInterpolatedU(u2), sprite.getInterpolatedV(v2)).color(f, f, f, a).endVertex();
|
||||
buffer.pos(middleX + x2, middleY + y1, blitOffset).tex(sprite.getInterpolatedU(u2), sprite.getInterpolatedV(v1)).color(f, f, f, a).endVertex();
|
||||
}
|
||||
|
||||
//Draw action icons
|
||||
@@ -327,7 +332,7 @@ public class RadialMenu extends GuiScreen {
|
||||
final double v1 = 0;
|
||||
final double v2 = 16;
|
||||
|
||||
final TextureAtlasSprite sprite = ClientProxy.getModeOptionIcon(button.action);
|
||||
final TextureAtlasSprite sprite = ModClientEventHandler.getModeOptionIcon(button.action);
|
||||
|
||||
final double btnmiddleX = (button.x1 + button.x2) / 2 + 0.01;
|
||||
final double btnmiddleY = (button.y1 + button.y2) / 2 + 0.01;
|
||||
@@ -336,25 +341,25 @@ public class RadialMenu extends GuiScreen {
|
||||
final double btny1 = btnmiddleY - 8;
|
||||
final double btny2 = btnmiddleY + 8;
|
||||
|
||||
buffer.pos(middleX + btnx1, middleY + btny1, zLevel).tex(sprite.getInterpolatedU(u1), sprite.getInterpolatedV(v1)).color(f, f, f, a).endVertex();
|
||||
buffer.pos(middleX + btnx1, middleY + btny2, zLevel).tex(sprite.getInterpolatedU(u1), sprite.getInterpolatedV(v2)).color(f, f, f, a).endVertex();
|
||||
buffer.pos(middleX + btnx2, middleY + btny2, zLevel).tex(sprite.getInterpolatedU(u2), sprite.getInterpolatedV(v2)).color(f, f, f, a).endVertex();
|
||||
buffer.pos(middleX + btnx2, middleY + btny1, zLevel).tex(sprite.getInterpolatedU(u2), sprite.getInterpolatedV(v1)).color(f, f, f, a).endVertex();
|
||||
buffer.pos(middleX + btnx1, middleY + btny1, blitOffset).tex(sprite.getInterpolatedU(u1), sprite.getInterpolatedV(v1)).color(f, f, f, a).endVertex();
|
||||
buffer.pos(middleX + btnx1, middleY + btny2, blitOffset).tex(sprite.getInterpolatedU(u1), sprite.getInterpolatedV(v2)).color(f, f, f, a).endVertex();
|
||||
buffer.pos(middleX + btnx2, middleY + btny2, blitOffset).tex(sprite.getInterpolatedU(u2), sprite.getInterpolatedV(v2)).color(f, f, f, a).endVertex();
|
||||
buffer.pos(middleX + btnx2, middleY + btny1, blitOffset).tex(sprite.getInterpolatedU(u2), sprite.getInterpolatedV(v1)).color(f, f, f, a).endVertex();
|
||||
}
|
||||
|
||||
tessellator.draw();
|
||||
|
||||
//Draw strings
|
||||
//fontRenderer.drawStringWithShadow("Actions", (int) (middleX - buttonDistance - 13) - fontRenderer.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
|
||||
for (int i = 0; i < currentBuildMode.options.length; i++) {
|
||||
OptionEnum option = options[i];
|
||||
fontRenderer.drawStringWithShadow(I18n.format(option.name), (int) (middleX + buttonDistance - 9), (int) middleY - 37 + i * 39, 0xeeeeeeff);
|
||||
font.drawStringWithShadow(I18n.format(option.name), (int) (middleX + buttonDistance - 9), (int) middleY - 37 + i * 39, 0xeeeeeeff);
|
||||
}
|
||||
|
||||
String credits = "Effortless Building";
|
||||
fontRenderer.drawStringWithShadow(credits, width - fontRenderer.getStringWidth(credits) - 4, height - 10, 0x88888888);
|
||||
font.drawStringWithShadow(credits, width - font.getStringWidth(credits) - 4, height - 10, 0x88888888);
|
||||
|
||||
//Draw buildmode text
|
||||
for (final MenuRegion menuRegion : modes) {
|
||||
@@ -364,16 +369,16 @@ public class RadialMenu extends GuiScreen {
|
||||
final double y = (menuRegion.y1 + menuRegion.y2) * 0.5;
|
||||
|
||||
int fixed_x = (int) (x * textDistance);
|
||||
final int fixed_y = (int) (y * textDistance) - fontRenderer.FONT_HEIGHT / 2;
|
||||
final int fixed_y = (int) (y * textDistance) - font.FONT_HEIGHT / 2;
|
||||
final String text = I18n.format(menuRegion.mode.name);
|
||||
|
||||
if ( x <= -0.2 ) {
|
||||
fixed_x -= fontRenderer.getStringWidth(text);
|
||||
fixed_x -= font.getStringWidth(text);
|
||||
} else if ( -0.2 <= x && x <= 0.2 ) {
|
||||
fixed_x -= fontRenderer.getStringWidth(text) / 2;
|
||||
fixed_x -= font.getStringWidth(text) / 2;
|
||||
}
|
||||
|
||||
fontRenderer.drawStringWithShadow(text, (int) middleX + fixed_x, (int) middleY + fixed_y, 0xffffffff);
|
||||
font.drawStringWithShadow(text, (int) middleX + fixed_x, (int) middleY + fixed_y, 0xffffffff);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -387,51 +392,51 @@ public class RadialMenu extends GuiScreen {
|
||||
|
||||
//Add keybind in brackets
|
||||
if (button.action == ActionEnum.UNDO) {
|
||||
keybind = ClientProxy.keyBindings[4].getKey().getName();
|
||||
keybind = ClientProxy.keyBindings[4].getLocalizedName();
|
||||
}
|
||||
if (button.action == ActionEnum.REDO) {
|
||||
keybind = ClientProxy.keyBindings[5].getKey().getName();
|
||||
keybind = ClientProxy.keyBindings[5].getLocalizedName();
|
||||
}
|
||||
if (button.action == ActionEnum.REPLACE) {
|
||||
keybind = ClientProxy.keyBindings[1].getKey().getName();
|
||||
keybind = ClientProxy.keyBindings[1].getLocalizedName();
|
||||
}
|
||||
if (button.action == ActionEnum.OPEN_MODIFIER_SETTINGS) {
|
||||
keybind = ClientProxy.keyBindings[0].getKey().getName();
|
||||
keybind = ClientProxy.keyBindings[0].getLocalizedName();
|
||||
}
|
||||
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 = ClientProxy.keyBindings[6].getKey().getName();
|
||||
keybind = ClientProxy.keyBindings[6].getLocalizedName();
|
||||
if (keybind.equals("Left Control")) keybind = "Ctrl";
|
||||
}
|
||||
}
|
||||
if (!keybind.isEmpty()) keybindFormatted = TextFormatting.GRAY + "(" + WordUtils.capitalizeFully(keybind) + ")";
|
||||
|
||||
if (button.textSide == EnumFacing.WEST) {
|
||||
if (button.textSide == Direction.WEST) {
|
||||
|
||||
fontRenderer.drawSplitString( text, (int) (middleX + button.x1 - 8 ) - fontRenderer.getStringWidth(text),
|
||||
font.drawSplitString( text, (int) (middleX + button.x1 - 8 ) - font.getStringWidth(text),
|
||||
(int) (middleY + button.y1 + 6), wrap, 0xffffffff);
|
||||
|
||||
} else if (button.textSide == EnumFacing.EAST) {
|
||||
} else if (button.textSide == Direction.EAST) {
|
||||
|
||||
fontRenderer.drawSplitString(text, (int) (middleX + button.x2 + 8),
|
||||
font.drawSplitString(text, (int) (middleX + button.x2 + 8),
|
||||
(int) (middleY + button.y1 + 6 ), wrap, 0xffffffff);
|
||||
|
||||
} else if (button.textSide == EnumFacing.UP || button.textSide == EnumFacing.NORTH) {
|
||||
} else if (button.textSide == Direction.UP || button.textSide == Direction.NORTH) {
|
||||
|
||||
fontRenderer.drawSplitString( keybindFormatted, (int) (middleX + (button.x1 + button.x2) * 0.5 - fontRenderer.getStringWidth(keybindFormatted) * 0.5),
|
||||
font.drawSplitString( keybindFormatted, (int) (middleX + (button.x1 + button.x2) * 0.5 - font.getStringWidth(keybindFormatted) * 0.5),
|
||||
(int) (middleY + button.y1 - 26), wrap,0xffffffff);
|
||||
|
||||
fontRenderer.drawSplitString( text, (int) (middleX + (button.x1 + button.x2) * 0.5 - fontRenderer.getStringWidth(text) * 0.5),
|
||||
font.drawSplitString( text, (int) (middleX + (button.x1 + button.x2) * 0.5 - font.getStringWidth(text) * 0.5),
|
||||
(int) (middleY + button.y1 - 14), wrap,0xffffffff);
|
||||
|
||||
} else if (button.textSide == EnumFacing.DOWN || button.textSide == EnumFacing.SOUTH) {
|
||||
} else if (button.textSide == Direction.DOWN || button.textSide == Direction.SOUTH) {
|
||||
|
||||
fontRenderer.drawSplitString(text, (int) (middleX + (button.x1 + button.x2) * 0.5 - fontRenderer.getStringWidth(text) * 0.5),
|
||||
font.drawSplitString(text, (int) (middleX + (button.x1 + button.x2) * 0.5 - font.getStringWidth(text) * 0.5),
|
||||
(int) (middleY + button.y1 + 26), wrap, 0xffffffff);
|
||||
|
||||
fontRenderer.drawSplitString(keybindFormatted, (int) (middleX + (button.x1 + button.x2) * 0.5 - fontRenderer.getStringWidth(keybindFormatted) * 0.5),
|
||||
font.drawSplitString(keybindFormatted, (int) (middleX + (button.x1 + button.x2) * 0.5 - font.getStringWidth(keybindFormatted) * 0.5),
|
||||
(int) (middleY + button.y1 + 38), wrap, 0xffffffff);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
package nl.requios.effortlessbuilding.gui.buildmodifier;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.Widget;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.client.config.GuiCheckBox;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.Array;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
|
||||
import nl.requios.effortlessbuilding.gui.elements.GuiCheckBoxFixed;
|
||||
import nl.requios.effortlessbuilding.gui.elements.GuiCollapsibleScrollEntry;
|
||||
import nl.requios.effortlessbuilding.gui.elements.GuiNumberField;
|
||||
import nl.requios.effortlessbuilding.gui.elements.GuiScrollPane;
|
||||
import nl.requios.effortlessbuilding.helper.ReachHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -24,7 +24,7 @@ public class ArraySettingsGui extends GuiCollapsibleScrollEntry {
|
||||
|
||||
protected List<GuiNumberField> arrayNumberFieldList = new ArrayList<>();
|
||||
|
||||
private GuiCheckBox buttonArrayEnabled;
|
||||
private GuiCheckBoxFixed buttonArrayEnabled;
|
||||
private GuiNumberField textArrayOffsetX, textArrayOffsetY, textArrayOffsetZ, textArrayCount;
|
||||
|
||||
public ArraySettingsGui(GuiScrollPane scrollPane) {
|
||||
@@ -32,11 +32,11 @@ public class ArraySettingsGui extends GuiCollapsibleScrollEntry {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int initGui(int id, List<GuiButton> buttons) {
|
||||
id = super.initGui(id, buttons);
|
||||
public void init(List<Widget> buttons) {
|
||||
super.init(buttons);
|
||||
|
||||
int y = top;
|
||||
buttonArrayEnabled = new GuiCheckBox(id++, left - 15 + 8, y, "", false) {
|
||||
buttonArrayEnabled = new GuiCheckBoxFixed(left - 15 + 8, y, "", false) {
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
@@ -46,23 +46,23 @@ public class ArraySettingsGui extends GuiCollapsibleScrollEntry {
|
||||
buttons.add(buttonArrayEnabled);
|
||||
|
||||
y = top + 20;
|
||||
textArrayOffsetX = new GuiNumberField(id++, id++, id++, fontRenderer, buttons, left + 70, y, 50, 18);
|
||||
textArrayOffsetX = new GuiNumberField(font, buttons, left + 70, y, 50, 18);
|
||||
textArrayOffsetX.setNumber(0);
|
||||
textArrayOffsetX.setTooltip("How much each copy is shifted.");
|
||||
arrayNumberFieldList.add(textArrayOffsetX);
|
||||
|
||||
textArrayOffsetY = new GuiNumberField(id++, id++, id++, fontRenderer, buttons, left + 140, y, 50, 18);
|
||||
textArrayOffsetY = new GuiNumberField(font, buttons, left + 140, y, 50, 18);
|
||||
textArrayOffsetY.setNumber(0);
|
||||
textArrayOffsetY.setTooltip("How much each copy is shifted.");
|
||||
arrayNumberFieldList.add(textArrayOffsetY);
|
||||
|
||||
textArrayOffsetZ = new GuiNumberField(id++, id++, id++, fontRenderer, buttons, left + 210, y, 50, 18);
|
||||
textArrayOffsetZ = new GuiNumberField(font, buttons, left + 210, y, 50, 18);
|
||||
textArrayOffsetZ.setNumber(0);
|
||||
textArrayOffsetZ.setTooltip("How much each copy is shifted.");
|
||||
arrayNumberFieldList.add(textArrayOffsetZ);
|
||||
|
||||
y = top + 50;
|
||||
textArrayCount = new GuiNumberField(id++, id++, id++, fontRenderer, buttons, left + 55, y, 50, 18);
|
||||
textArrayCount = new GuiNumberField(font, buttons, left + 55, y, 50, 18);
|
||||
textArrayCount.setNumber(5);
|
||||
textArrayCount.setTooltip("How many copies should be made.");
|
||||
arrayNumberFieldList.add(textArrayCount);
|
||||
@@ -78,8 +78,6 @@ public class ArraySettingsGui extends GuiCollapsibleScrollEntry {
|
||||
}
|
||||
|
||||
setCollapsed(!buttonArrayEnabled.isChecked());
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
public void updateScreen() {
|
||||
@@ -95,36 +93,36 @@ public class ArraySettingsGui extends GuiCollapsibleScrollEntry {
|
||||
buttonArrayEnabled.render(mouseX, mouseY, partialTicks);
|
||||
if (buttonArrayEnabled.isChecked()) {
|
||||
buttonArrayEnabled.y = yy;
|
||||
fontRenderer.drawString("Array enabled", left + offset, yy + 2, 0xFFFFFF);
|
||||
font.drawString("Array enabled", left + offset, yy + 2, 0xFFFFFF);
|
||||
|
||||
yy = y + 20;
|
||||
fontRenderer.drawString("Offset", left + offset, yy + 5, 0xFFFFFF);
|
||||
fontRenderer.drawString("X", left + 50 + offset, yy + 5, 0xFFFFFF);
|
||||
font.drawString("Offset", left + offset, yy + 5, 0xFFFFFF);
|
||||
font.drawString("X", left + 50 + offset, yy + 5, 0xFFFFFF);
|
||||
textArrayOffsetX.y = yy;
|
||||
fontRenderer.drawString("Y", left + 120 + offset, yy + 5, 0xFFFFFF);
|
||||
font.drawString("Y", left + 120 + offset, yy + 5, 0xFFFFFF);
|
||||
textArrayOffsetY.y = yy;
|
||||
fontRenderer.drawString("Z", left + 190 + offset, yy + 5, 0xFFFFFF);
|
||||
font.drawString("Z", left + 190 + offset, yy + 5, 0xFFFFFF);
|
||||
textArrayOffsetZ.y = yy;
|
||||
|
||||
yy = y + 50;
|
||||
fontRenderer.drawString("Count", left + offset, yy + 5, 0xFFFFFF);
|
||||
font.drawString("Count", left + offset, yy + 5, 0xFFFFFF);
|
||||
textArrayCount.y = yy;
|
||||
|
||||
int currentReach = Math.max(-1, getArrayReach());
|
||||
int maxReach = ReachHelper.getMaxReach(mc.player);
|
||||
TextFormatting reachColor = isCurrentReachValid(currentReach, maxReach) ? TextFormatting.GRAY : TextFormatting.RED;
|
||||
String reachText = "Reach: " + reachColor + currentReach + TextFormatting.GRAY + "/" + TextFormatting.GRAY + maxReach;
|
||||
fontRenderer.drawString(reachText, left + 176 + offset, yy + 5, 0xFFFFFF);
|
||||
font.drawString(reachText, left + 176 + offset, yy + 5, 0xFFFFFF);
|
||||
|
||||
arrayNumberFieldList.forEach(numberField -> numberField.drawNumberField(mouseX, mouseY, partialTicks));
|
||||
} else {
|
||||
buttonArrayEnabled.y = yy;
|
||||
fontRenderer.drawString("Array disabled", left + offset, yy + 2, 0x999999);
|
||||
font.drawString("Array disabled", left + offset, yy + 2, 0x999999);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void drawTooltip(GuiScreen guiScreen, int mouseX, int mouseY) {
|
||||
public void drawTooltip(Screen guiScreen, int mouseX, int mouseY) {
|
||||
//Draw tooltips last
|
||||
if (buttonArrayEnabled.isChecked())
|
||||
{
|
||||
@@ -148,7 +146,7 @@ public class ArraySettingsGui extends GuiCollapsibleScrollEntry {
|
||||
boolean insideArrayEnabledLabel = mouseX >= left && mouseX < right && relativeY >= -2 && relativeY < 12;
|
||||
|
||||
if (insideArrayEnabledLabel) {
|
||||
buttonArrayEnabled.playPressSound(this.mc.getSoundHandler());
|
||||
buttonArrayEnabled.playDownSound(this.mc.getSoundHandler());
|
||||
buttonArrayEnabled.onClick(mouseX, mouseY);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,23 +1,19 @@
|
||||
package nl.requios.effortlessbuilding.gui.buildmodifier;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.widget.Widget;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.client.config.GuiCheckBox;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.Mirror;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
|
||||
import nl.requios.effortlessbuilding.gui.elements.GuiCollapsibleScrollEntry;
|
||||
import nl.requios.effortlessbuilding.gui.elements.GuiIconButton;
|
||||
import nl.requios.effortlessbuilding.gui.elements.GuiNumberField;
|
||||
import nl.requios.effortlessbuilding.gui.elements.GuiScrollPane;
|
||||
import nl.requios.effortlessbuilding.gui.elements.*;
|
||||
import nl.requios.effortlessbuilding.helper.ReachHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -28,12 +24,12 @@ public class MirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
||||
|
||||
protected static final ResourceLocation BUILDING_ICONS = new ResourceLocation(EffortlessBuilding.MODID, "textures/gui/building_icons.png");
|
||||
|
||||
protected List<GuiButton> mirrorButtonList = new ArrayList<>();
|
||||
protected List<Button> mirrorButtonList = new ArrayList<>();
|
||||
protected List<GuiIconButton> mirrorIconButtonList = new ArrayList<>();
|
||||
protected List<GuiNumberField> mirrorNumberFieldList = new ArrayList<>();
|
||||
|
||||
private GuiNumberField textMirrorPosX, textMirrorPosY, textMirrorPosZ, textMirrorRadius;
|
||||
private GuiCheckBox buttonMirrorEnabled, buttonMirrorX, buttonMirrorY, buttonMirrorZ;
|
||||
private GuiCheckBoxFixed buttonMirrorEnabled, buttonMirrorX, buttonMirrorY, buttonMirrorZ;
|
||||
private GuiIconButton buttonCurrentPosition, buttonToggleOdd, buttonDrawPlanes, buttonDrawLines;
|
||||
private boolean drawPlanes, drawLines, toggleOdd;
|
||||
|
||||
@@ -42,11 +38,11 @@ public class MirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int initGui(int id, List<GuiButton> buttonList) {
|
||||
id = super.initGui(id, buttonList);
|
||||
public void init(List<Widget> buttonList) {
|
||||
super.init(buttonList);
|
||||
|
||||
int y = top - 2;
|
||||
buttonMirrorEnabled = new GuiCheckBox(id++, left - 15 + 8, y, "", false) {
|
||||
buttonMirrorEnabled = new GuiCheckBoxFixed(left - 15 + 8, y, "", false) {
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
@@ -56,34 +52,34 @@ public class MirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
||||
buttonList.add(buttonMirrorEnabled);
|
||||
|
||||
y = top + 18;
|
||||
textMirrorPosX = new GuiNumberField(id++, id++, id++, fontRenderer, buttonList, left + 58, y, 62, 18);
|
||||
textMirrorPosX = new GuiNumberField(font, buttonList, left + 58, y, 62, 18);
|
||||
textMirrorPosX.setNumber(0);
|
||||
textMirrorPosX.setTooltip(
|
||||
Arrays.asList("The position of the mirror.", TextFormatting.GRAY + "For odd numbered builds add 0.5."));
|
||||
mirrorNumberFieldList.add(textMirrorPosX);
|
||||
|
||||
textMirrorPosY = new GuiNumberField(id++, id++, id++, fontRenderer, buttonList, left + 138, y, 62, 18);
|
||||
textMirrorPosY = new GuiNumberField(font, buttonList, left + 138, y, 62, 18);
|
||||
textMirrorPosY.setNumber(64);
|
||||
textMirrorPosY.setTooltip(Arrays.asList("The position of the mirror.", TextFormatting.GRAY + "For odd numbered builds add 0.5."));
|
||||
mirrorNumberFieldList.add(textMirrorPosY);
|
||||
|
||||
textMirrorPosZ = new GuiNumberField(id++, id++, id++, fontRenderer, buttonList, left + 218, y, 62, 18);
|
||||
textMirrorPosZ = new GuiNumberField(font, buttonList, left + 218, y, 62, 18);
|
||||
textMirrorPosZ.setNumber(0);
|
||||
textMirrorPosZ.setTooltip(Arrays.asList("The position of the mirror.", TextFormatting.GRAY + "For odd numbered builds add 0.5."));
|
||||
mirrorNumberFieldList.add(textMirrorPosZ);
|
||||
|
||||
y = top + 50;
|
||||
buttonMirrorX = new GuiCheckBox(id++, left + 60, y, " X", true);
|
||||
buttonMirrorX = new GuiCheckBoxFixed(left + 60, y, " X", true);
|
||||
mirrorButtonList.add(buttonMirrorX);
|
||||
|
||||
buttonMirrorY = new GuiCheckBox(id++, left + 100, y, " Y", false);
|
||||
buttonMirrorY = new GuiCheckBoxFixed(left + 100, y, " Y", false);
|
||||
mirrorButtonList.add(buttonMirrorY);
|
||||
|
||||
buttonMirrorZ = new GuiCheckBox(id++, left + 140, y, " Z", false);
|
||||
buttonMirrorZ = new GuiCheckBoxFixed(left + 140, y, " Z", false);
|
||||
mirrorButtonList.add(buttonMirrorZ);
|
||||
|
||||
y = top + 47;
|
||||
textMirrorRadius = new GuiNumberField(id++, id++, id++, fontRenderer, buttonList, left + 218, y, 62, 18);
|
||||
textMirrorRadius = new GuiNumberField(font, buttonList, left + 218, y, 62, 18);
|
||||
textMirrorRadius.setNumber(50);
|
||||
//TODO change to diameter (remove /2)
|
||||
textMirrorRadius.setTooltip(Arrays.asList("How far the mirror reaches in any direction.",
|
||||
@@ -92,62 +88,46 @@ public class MirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
||||
mirrorNumberFieldList.add(textMirrorRadius);
|
||||
|
||||
y = top + 72;
|
||||
buttonCurrentPosition = new GuiIconButton(id++, left + 5, y, 0, 0, BUILDING_ICONS) {
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
Vec3d pos = new Vec3d(Math.floor(mc.player.posX) + 0.5, Math.floor(mc.player.posY) + 0.5, Math.floor(mc.player.posZ) + 0.5);
|
||||
textMirrorPosX.setNumber(pos.x);
|
||||
textMirrorPosY.setNumber(pos.y);
|
||||
textMirrorPosZ.setNumber(pos.z);
|
||||
}
|
||||
};
|
||||
buttonCurrentPosition = new GuiIconButton(left + 5, y, 0, 0, BUILDING_ICONS, button -> {
|
||||
Vec3d pos = new Vec3d(Math.floor(mc.player.posX) + 0.5, Math.floor(mc.player.posY) + 0.5, Math.floor(mc.player.posZ) + 0.5);
|
||||
textMirrorPosX.setNumber(pos.x);
|
||||
textMirrorPosY.setNumber(pos.y);
|
||||
textMirrorPosZ.setNumber(pos.z);
|
||||
});
|
||||
buttonCurrentPosition.setTooltip("Set mirror position to current player position");
|
||||
mirrorIconButtonList.add(buttonCurrentPosition);
|
||||
|
||||
buttonToggleOdd = new GuiIconButton(id++, left + 35, y, 0, 20, BUILDING_ICONS) {
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
toggleOdd = !toggleOdd;
|
||||
buttonToggleOdd.setUseAlternateIcon(toggleOdd);
|
||||
if (toggleOdd) {
|
||||
buttonToggleOdd.setTooltip(Arrays.asList("Set mirror position to corner of block", "for even numbered builds"));
|
||||
textMirrorPosX.setNumber(textMirrorPosX.getNumber() + 0.5);
|
||||
textMirrorPosY.setNumber(textMirrorPosY.getNumber() + 0.5);
|
||||
textMirrorPosZ.setNumber(textMirrorPosZ.getNumber() + 0.5);
|
||||
} else {
|
||||
buttonToggleOdd.setTooltip(Arrays.asList("Set mirror position to middle of block", "for odd numbered builds"));
|
||||
textMirrorPosX.setNumber(Math.floor(textMirrorPosX.getNumber()));
|
||||
textMirrorPosY.setNumber(Math.floor(textMirrorPosY.getNumber()));
|
||||
textMirrorPosZ.setNumber(Math.floor(textMirrorPosZ.getNumber()));
|
||||
}
|
||||
buttonToggleOdd = new GuiIconButton(left + 35, y, 0, 20, BUILDING_ICONS, button -> {
|
||||
toggleOdd = !toggleOdd;
|
||||
buttonToggleOdd.setUseAlternateIcon(toggleOdd);
|
||||
if (toggleOdd) {
|
||||
buttonToggleOdd.setTooltip(Arrays.asList("Set mirror position to corner of block", "for even numbered builds"));
|
||||
textMirrorPosX.setNumber(textMirrorPosX.getNumber() + 0.5);
|
||||
textMirrorPosY.setNumber(textMirrorPosY.getNumber() + 0.5);
|
||||
textMirrorPosZ.setNumber(textMirrorPosZ.getNumber() + 0.5);
|
||||
} else {
|
||||
buttonToggleOdd.setTooltip(Arrays.asList("Set mirror position to middle of block", "for odd numbered builds"));
|
||||
textMirrorPosX.setNumber(Math.floor(textMirrorPosX.getNumber()));
|
||||
textMirrorPosY.setNumber(Math.floor(textMirrorPosY.getNumber()));
|
||||
textMirrorPosZ.setNumber(Math.floor(textMirrorPosZ.getNumber()));
|
||||
}
|
||||
};
|
||||
});
|
||||
buttonToggleOdd.setTooltip(Arrays.asList("Set mirror position to middle of block", "for odd numbered builds"));
|
||||
mirrorIconButtonList.add(buttonToggleOdd);
|
||||
|
||||
buttonDrawLines = new GuiIconButton(id++, left + 65, y, 0, 40, BUILDING_ICONS) {
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
drawLines = !drawLines;
|
||||
buttonDrawLines.setUseAlternateIcon(drawLines);
|
||||
buttonDrawLines.setTooltip(drawLines ? "Hide lines" : "Show lines");
|
||||
}
|
||||
};
|
||||
buttonDrawLines = new GuiIconButton(left + 65, y, 0, 40, BUILDING_ICONS, button -> {
|
||||
drawLines = !drawLines;
|
||||
buttonDrawLines.setUseAlternateIcon(drawLines);
|
||||
buttonDrawLines.setTooltip(drawLines ? "Hide lines" : "Show lines");
|
||||
});
|
||||
buttonDrawLines.setTooltip("Show lines");
|
||||
mirrorIconButtonList.add(buttonDrawLines);
|
||||
|
||||
buttonDrawPlanes = new GuiIconButton(id++, left + 95, y, 0, 60, BUILDING_ICONS) {
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
drawPlanes = !drawPlanes;
|
||||
buttonDrawPlanes.setUseAlternateIcon(drawPlanes);
|
||||
buttonDrawPlanes.setTooltip(drawPlanes ? "Hide area" : "Show area");
|
||||
}
|
||||
};
|
||||
buttonDrawPlanes = new GuiIconButton(left + 95, y, 0, 60, BUILDING_ICONS, button -> {
|
||||
drawPlanes = !drawPlanes;
|
||||
buttonDrawPlanes.setUseAlternateIcon(drawPlanes);
|
||||
buttonDrawPlanes.setTooltip(drawPlanes ? "Hide area" : "Show area");
|
||||
});
|
||||
buttonDrawPlanes.setTooltip("Show area");
|
||||
mirrorIconButtonList.add(buttonDrawPlanes);
|
||||
|
||||
@@ -182,8 +162,6 @@ public class MirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
||||
buttonList.addAll(mirrorIconButtonList);
|
||||
|
||||
setCollapsed(!buttonMirrorEnabled.isChecked());
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -202,23 +180,23 @@ public class MirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
||||
buttonMirrorEnabled.render(mouseX, mouseY, partialTicks);
|
||||
if (buttonMirrorEnabled.isChecked()) {
|
||||
buttonMirrorEnabled.y = yy;
|
||||
fontRenderer.drawString("Mirror enabled", left + offset, yy + 2, 0xFFFFFF);
|
||||
font.drawString("Mirror enabled", left + offset, yy + 2, 0xFFFFFF);
|
||||
|
||||
yy = y + 18;
|
||||
fontRenderer.drawString("Position", left + offset, yy + 5, 0xFFFFFF);
|
||||
fontRenderer.drawString("X", left + 40 + offset, yy + 5, 0xFFFFFF);
|
||||
font.drawString("Position", left + offset, yy + 5, 0xFFFFFF);
|
||||
font.drawString("X", left + 40 + offset, yy + 5, 0xFFFFFF);
|
||||
textMirrorPosX.y = yy;
|
||||
fontRenderer.drawString("Y", left + 120 + offset, yy + 5, 0xFFFFFF);
|
||||
font.drawString("Y", left + 120 + offset, yy + 5, 0xFFFFFF);
|
||||
textMirrorPosY.y = yy;
|
||||
fontRenderer.drawString("Z", left + 200 + offset, yy + 5, 0xFFFFFF);
|
||||
font.drawString("Z", left + 200 + offset, yy + 5, 0xFFFFFF);
|
||||
textMirrorPosZ.y = yy;
|
||||
|
||||
yy = y + 50;
|
||||
fontRenderer.drawString("Direction", left + offset, yy + 2, 0xFFFFFF);
|
||||
font.drawString("Direction", left + offset, yy + 2, 0xFFFFFF);
|
||||
buttonMirrorX.y = yy;
|
||||
buttonMirrorY.y = yy;
|
||||
buttonMirrorZ.y = yy;
|
||||
fontRenderer.drawString("Radius", left + 176 + offset, yy + 2, 0xFFFFFF);
|
||||
font.drawString("Radius", left + 176 + offset, yy + 2, 0xFFFFFF);
|
||||
textMirrorRadius.y = yy - 3;
|
||||
|
||||
yy = y + 72;
|
||||
@@ -232,12 +210,12 @@ public class MirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
||||
mirrorNumberFieldList.forEach(numberField -> numberField.drawNumberField(mouseX, mouseY, partialTicks));
|
||||
} else {
|
||||
buttonMirrorEnabled.y = yy;
|
||||
fontRenderer.drawString("Mirror disabled", left + offset, yy + 2, 0x999999);
|
||||
font.drawString("Mirror disabled", left + offset, yy + 2, 0x999999);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void drawTooltip(GuiScreen guiScreen, int mouseX, int mouseY) {
|
||||
public void drawTooltip(Screen guiScreen, int mouseX, int mouseY) {
|
||||
//Draw tooltips last
|
||||
if (buttonMirrorEnabled.isChecked())
|
||||
{
|
||||
@@ -262,7 +240,7 @@ public class MirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
||||
boolean insideMirrorEnabledLabel = mouseX >= left && mouseX < right && relativeY >= -2 && relativeY < 12;
|
||||
|
||||
if (insideMirrorEnabledLabel) {
|
||||
buttonMirrorEnabled.playPressSound(this.mc.getSoundHandler());
|
||||
buttonMirrorEnabled.playDownSound(this.mc.getSoundHandler());
|
||||
buttonMirrorEnabled.onClick(mouseX, mouseY);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package nl.requios.effortlessbuilding.gui.buildmodifier;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
@@ -15,24 +17,24 @@ import nl.requios.effortlessbuilding.network.ModifierSettingsMessage;
|
||||
import nl.requios.effortlessbuilding.network.PacketHandler;
|
||||
import nl.requios.effortlessbuilding.proxy.ClientProxy;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ModifierSettingsGui extends GuiScreen {
|
||||
public class ModifierSettingsGui extends Screen {
|
||||
|
||||
private GuiScrollPane scrollPane;
|
||||
private GuiButton buttonClose;
|
||||
private Button buttonClose;
|
||||
|
||||
private MirrorSettingsGui mirrorSettingsGui;
|
||||
private ArraySettingsGui arraySettingsGui;
|
||||
private RadialMirrorSettingsGui radialMirrorSettingsGui;
|
||||
|
||||
public ModifierSettingsGui() {
|
||||
super(new TranslationTextComponent("effortlessbuilding.screen.modifier_settings"));
|
||||
}
|
||||
|
||||
@Override
|
||||
//Create buttons and labels and add them to buttonList/labelList
|
||||
public void initGui() {
|
||||
int id = 0;
|
||||
|
||||
scrollPane = new GuiScrollPane(this, fontRenderer, 8, height - 30);
|
||||
protected void init() {
|
||||
scrollPane = new GuiScrollPane(this, font, 8, height - 30);
|
||||
|
||||
mirrorSettingsGui = new MirrorSettingsGui(scrollPane);
|
||||
scrollPane.AddListEntry(mirrorSettingsGui);
|
||||
@@ -43,19 +45,14 @@ public class ModifierSettingsGui extends GuiScreen {
|
||||
radialMirrorSettingsGui = new RadialMirrorSettingsGui(scrollPane);
|
||||
scrollPane.AddListEntry(radialMirrorSettingsGui);
|
||||
|
||||
id = scrollPane.initGui(id, buttons);
|
||||
scrollPane.init(buttons);
|
||||
|
||||
//Close button
|
||||
int y = height - 26;
|
||||
buttonClose = new GuiButton(id++, width / 2 - 100, y, "Close") {
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
mc.player.closeScreen();
|
||||
}
|
||||
};
|
||||
buttonClose = new Button(width / 2 - 100, y, 200, 20, "Close", (button) -> {
|
||||
Minecraft.getInstance().player.closeScreen();
|
||||
});
|
||||
buttons.add(buttonClose);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,12 +64,12 @@ public class ModifierSettingsGui extends GuiScreen {
|
||||
}
|
||||
|
||||
@Override
|
||||
//Set colors using GL11, use the fontRendererObj field to display text
|
||||
//Set colors using GL11, use the fontObj field to display text
|
||||
//Use drawTexturedModalRect() to transfers areas of a texture resource to the screen
|
||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||
this.drawDefaultBackground();
|
||||
this.renderBackground();
|
||||
|
||||
scrollPane.drawScreen(mouseX, mouseY, partialTicks);
|
||||
scrollPane.render(mouseX, mouseY, partialTicks);
|
||||
|
||||
buttonClose.render(mouseX, mouseY, partialTicks);
|
||||
|
||||
@@ -85,7 +82,7 @@ public class ModifierSettingsGui extends GuiScreen {
|
||||
super.charTyped(typedChar, keyCode);
|
||||
scrollPane.charTyped(typedChar, keyCode);
|
||||
if (keyCode == ClientProxy.keyBindings[0].getKey().getKeyCode()) {
|
||||
mc.player.closeScreen();
|
||||
minecraft.player.closeScreen();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -117,7 +114,7 @@ public class ModifierSettingsGui extends GuiScreen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
public void removed() {
|
||||
scrollPane.onGuiClosed();
|
||||
|
||||
//save everything
|
||||
@@ -125,17 +122,17 @@ public class ModifierSettingsGui extends GuiScreen {
|
||||
Array.ArraySettings a = arraySettingsGui.getArraySettings();
|
||||
RadialMirror.RadialMirrorSettings r = radialMirrorSettingsGui.getRadialMirrorSettings();
|
||||
|
||||
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(mc.player);
|
||||
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(minecraft.player);
|
||||
if (modifierSettings == null) modifierSettings = new ModifierSettingsManager.ModifierSettings();
|
||||
modifierSettings.setMirrorSettings(m);
|
||||
modifierSettings.setArraySettings(a);
|
||||
modifierSettings.setRadialMirrorSettings(r);
|
||||
|
||||
//Sanitize
|
||||
String error = ModifierSettingsManager.sanitize(modifierSettings, mc.player);
|
||||
if (!error.isEmpty()) EffortlessBuilding.log(mc.player, error);
|
||||
String error = ModifierSettingsManager.sanitize(modifierSettings, minecraft.player);
|
||||
if (!error.isEmpty()) EffortlessBuilding.log(minecraft.player, error);
|
||||
|
||||
ModifierSettingsManager.setModifierSettings(mc.player, modifierSettings);
|
||||
ModifierSettingsManager.setModifierSettings(minecraft.player, modifierSettings);
|
||||
|
||||
//Send to server
|
||||
PacketHandler.INSTANCE.sendToServer(new ModifierSettingsMessage(modifierSettings));
|
||||
|
||||
@@ -1,23 +1,19 @@
|
||||
package nl.requios.effortlessbuilding.gui.buildmodifier;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.widget.Widget;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.client.config.GuiCheckBox;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.RadialMirror;
|
||||
import nl.requios.effortlessbuilding.gui.elements.GuiCollapsibleScrollEntry;
|
||||
import nl.requios.effortlessbuilding.gui.elements.GuiIconButton;
|
||||
import nl.requios.effortlessbuilding.gui.elements.GuiNumberField;
|
||||
import nl.requios.effortlessbuilding.gui.elements.GuiScrollPane;
|
||||
import nl.requios.effortlessbuilding.gui.elements.*;
|
||||
import nl.requios.effortlessbuilding.helper.ReachHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -28,12 +24,12 @@ public class RadialMirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
||||
|
||||
protected static final ResourceLocation BUILDING_ICONS = new ResourceLocation(EffortlessBuilding.MODID, "textures/gui/building_icons.png");
|
||||
|
||||
protected List<GuiButton> radialMirrorButtonList = new ArrayList<>();
|
||||
protected List<Button> radialMirrorButtonList = new ArrayList<>();
|
||||
protected List<GuiIconButton> radialMirrorIconButtonList = new ArrayList<>();
|
||||
protected List<GuiNumberField> radialMirrorNumberFieldList = new ArrayList<>();
|
||||
|
||||
private GuiNumberField textRadialMirrorPosX, textRadialMirrorPosY, textRadialMirrorPosZ, textRadialMirrorSlices, textRadialMirrorRadius;
|
||||
private GuiCheckBox buttonRadialMirrorEnabled, buttonRadialMirrorAlternate;
|
||||
private GuiCheckBoxFixed buttonRadialMirrorEnabled, buttonRadialMirrorAlternate;
|
||||
private GuiIconButton buttonCurrentPosition, buttonToggleOdd, buttonDrawPlanes, buttonDrawLines;
|
||||
private boolean drawPlanes, drawLines, toggleOdd;
|
||||
|
||||
@@ -42,11 +38,11 @@ public class RadialMirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int initGui(int id, List<GuiButton> buttonList) {
|
||||
id = super.initGui(id, buttonList);
|
||||
public void init(List<Widget> buttonList) {
|
||||
super.init(buttonList);
|
||||
|
||||
int y = top - 2;
|
||||
buttonRadialMirrorEnabled = new GuiCheckBox(id++, left - 15 + 8, y, "", false) {
|
||||
buttonRadialMirrorEnabled = new GuiCheckBoxFixed(left - 15 + 8, y, "", false) {
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
@@ -56,29 +52,29 @@ public class RadialMirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
||||
buttonList.add(buttonRadialMirrorEnabled);
|
||||
|
||||
y = top + 18;
|
||||
textRadialMirrorPosX = new GuiNumberField(id++, id++, id++, fontRenderer, buttonList, left + 58, y, 62, 18);
|
||||
textRadialMirrorPosX = new GuiNumberField(font, buttonList, left + 58, y, 62, 18);
|
||||
textRadialMirrorPosX.setNumber(0);
|
||||
textRadialMirrorPosX.setTooltip(
|
||||
Arrays.asList("The position of the radial mirror.", TextFormatting.GRAY + "For odd numbered builds add 0.5."));
|
||||
radialMirrorNumberFieldList.add(textRadialMirrorPosX);
|
||||
|
||||
textRadialMirrorPosY = new GuiNumberField(id++, id++, id++, fontRenderer, buttonList, left + 138, y, 62, 18);
|
||||
textRadialMirrorPosY = new GuiNumberField(font, buttonList, left + 138, y, 62, 18);
|
||||
textRadialMirrorPosY.setNumber(64);
|
||||
textRadialMirrorPosY.setTooltip(Arrays.asList("The position of the radial mirror.", TextFormatting.GRAY + "For odd numbered builds add 0.5."));
|
||||
radialMirrorNumberFieldList.add(textRadialMirrorPosY);
|
||||
|
||||
textRadialMirrorPosZ = new GuiNumberField(id++, id++, id++, fontRenderer, buttonList, left + 218, y, 62, 18);
|
||||
textRadialMirrorPosZ = new GuiNumberField(font, buttonList, left + 218, y, 62, 18);
|
||||
textRadialMirrorPosZ.setNumber(0);
|
||||
textRadialMirrorPosZ.setTooltip(Arrays.asList("The position of the radial mirror.", TextFormatting.GRAY + "For odd numbered builds add 0.5."));
|
||||
radialMirrorNumberFieldList.add(textRadialMirrorPosZ);
|
||||
|
||||
y = top + 47;
|
||||
textRadialMirrorSlices = new GuiNumberField(id++, id++, id++, fontRenderer, buttonList, left + 55, y, 50, 18);
|
||||
textRadialMirrorSlices = new GuiNumberField(font, buttonList, left + 55, y, 50, 18);
|
||||
textRadialMirrorSlices.setNumber(4);
|
||||
textRadialMirrorSlices.setTooltip(Arrays.asList("The number of repeating slices.", TextFormatting.GRAY + "Minimally 2."));
|
||||
radialMirrorNumberFieldList.add(textRadialMirrorSlices);
|
||||
|
||||
textRadialMirrorRadius = new GuiNumberField(id++, id++, id++, fontRenderer, buttonList, left + 218, y, 62, 18);
|
||||
textRadialMirrorRadius = new GuiNumberField(font, buttonList, left + 218, y, 62, 18);
|
||||
textRadialMirrorRadius.setNumber(50);
|
||||
//TODO change to diameter (remove /2)
|
||||
textRadialMirrorRadius.setTooltip(Arrays.asList("How far the radial mirror reaches from its center position.",
|
||||
@@ -87,67 +83,51 @@ public class RadialMirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
||||
radialMirrorNumberFieldList.add(textRadialMirrorRadius);
|
||||
|
||||
y = top + 72;
|
||||
buttonCurrentPosition = new GuiIconButton(id++, left + 5, y, 0, 0, BUILDING_ICONS) {
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
Vec3d pos = new Vec3d(Math.floor(mc.player.posX) + 0.5, Math.floor(mc.player.posY) + 0.5, Math.floor(mc.player.posZ) + 0.5);
|
||||
textRadialMirrorPosX.setNumber(pos.x);
|
||||
textRadialMirrorPosY.setNumber(pos.y);
|
||||
textRadialMirrorPosZ.setNumber(pos.z);
|
||||
}
|
||||
};
|
||||
buttonCurrentPosition = new GuiIconButton(left + 5, y, 0, 0, BUILDING_ICONS, button -> {
|
||||
Vec3d pos = new Vec3d(Math.floor(mc.player.posX) + 0.5, Math.floor(mc.player.posY) + 0.5, Math.floor(mc.player.posZ) + 0.5);
|
||||
textRadialMirrorPosX.setNumber(pos.x);
|
||||
textRadialMirrorPosY.setNumber(pos.y);
|
||||
textRadialMirrorPosZ.setNumber(pos.z);
|
||||
});
|
||||
buttonCurrentPosition.setTooltip("Set radial mirror position to current player position");
|
||||
radialMirrorIconButtonList.add(buttonCurrentPosition);
|
||||
|
||||
buttonToggleOdd = new GuiIconButton(id++, left + 35, y, 0, 20, BUILDING_ICONS) {
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
toggleOdd = !toggleOdd;
|
||||
buttonToggleOdd.setUseAlternateIcon(toggleOdd);
|
||||
if (toggleOdd) {
|
||||
buttonToggleOdd.setTooltip(Arrays.asList("Set mirror position to corner of block", "for even numbered builds"));
|
||||
textRadialMirrorPosX.setNumber(textRadialMirrorPosX.getNumber() + 0.5);
|
||||
textRadialMirrorPosY.setNumber(textRadialMirrorPosY.getNumber() + 0.5);
|
||||
textRadialMirrorPosZ.setNumber(textRadialMirrorPosZ.getNumber() + 0.5);
|
||||
} else {
|
||||
buttonToggleOdd.setTooltip(Arrays.asList("Set mirror position to middle of block", "for odd numbered builds"));
|
||||
textRadialMirrorPosX.setNumber(Math.floor(textRadialMirrorPosX.getNumber()));
|
||||
textRadialMirrorPosY.setNumber(Math.floor(textRadialMirrorPosY.getNumber()));
|
||||
textRadialMirrorPosZ.setNumber(Math.floor(textRadialMirrorPosZ.getNumber()));
|
||||
}
|
||||
buttonToggleOdd = new GuiIconButton(left + 35, y, 0, 20, BUILDING_ICONS, button -> {
|
||||
toggleOdd = !toggleOdd;
|
||||
buttonToggleOdd.setUseAlternateIcon(toggleOdd);
|
||||
if (toggleOdd) {
|
||||
buttonToggleOdd.setTooltip(Arrays.asList("Set mirror position to corner of block", "for even numbered builds"));
|
||||
textRadialMirrorPosX.setNumber(textRadialMirrorPosX.getNumber() + 0.5);
|
||||
textRadialMirrorPosY.setNumber(textRadialMirrorPosY.getNumber() + 0.5);
|
||||
textRadialMirrorPosZ.setNumber(textRadialMirrorPosZ.getNumber() + 0.5);
|
||||
} else {
|
||||
buttonToggleOdd.setTooltip(Arrays.asList("Set mirror position to middle of block", "for odd numbered builds"));
|
||||
textRadialMirrorPosX.setNumber(Math.floor(textRadialMirrorPosX.getNumber()));
|
||||
textRadialMirrorPosY.setNumber(Math.floor(textRadialMirrorPosY.getNumber()));
|
||||
textRadialMirrorPosZ.setNumber(Math.floor(textRadialMirrorPosZ.getNumber()));
|
||||
}
|
||||
};
|
||||
});
|
||||
buttonToggleOdd.setTooltip(Arrays.asList("Set radial mirror position to middle of block", "for odd numbered builds"));
|
||||
radialMirrorIconButtonList.add(buttonToggleOdd);
|
||||
|
||||
buttonDrawLines = new GuiIconButton(id++, left + 65, y, 0, 40, BUILDING_ICONS) {
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
drawLines = !drawLines;
|
||||
buttonDrawLines.setUseAlternateIcon(drawLines);
|
||||
buttonDrawLines.setTooltip(drawLines ? "Hide lines" : "Show lines");
|
||||
}
|
||||
};
|
||||
buttonDrawLines = new GuiIconButton(left + 65, y, 0, 40, BUILDING_ICONS, button -> {
|
||||
drawLines = !drawLines;
|
||||
buttonDrawLines.setUseAlternateIcon(drawLines);
|
||||
buttonDrawLines.setTooltip(drawLines ? "Hide lines" : "Show lines");
|
||||
});
|
||||
buttonDrawLines.setTooltip("Show lines");
|
||||
radialMirrorIconButtonList.add(buttonDrawLines);
|
||||
|
||||
buttonDrawPlanes = new GuiIconButton(id++, left + 95, y, 0, 60, BUILDING_ICONS) {
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
drawPlanes = !drawPlanes;
|
||||
buttonDrawPlanes.setUseAlternateIcon(drawPlanes);
|
||||
buttonDrawPlanes.setTooltip(drawPlanes ? "Hide area" : "Show area");
|
||||
}
|
||||
};
|
||||
buttonDrawPlanes = new GuiIconButton(left + 95, y, 0, 60, BUILDING_ICONS, button -> {
|
||||
drawPlanes = !drawPlanes;
|
||||
buttonDrawPlanes.setUseAlternateIcon(drawPlanes);
|
||||
buttonDrawPlanes.setTooltip(drawPlanes ? "Hide area" : "Show area");
|
||||
});
|
||||
buttonDrawPlanes.setTooltip("Show area");
|
||||
radialMirrorIconButtonList.add(buttonDrawPlanes);
|
||||
|
||||
y = top + 76;
|
||||
buttonRadialMirrorAlternate = new GuiCheckBox(id++, left + 140, y, " Alternate", false);
|
||||
buttonRadialMirrorAlternate = new GuiCheckBoxFixed(left + 140, y, " Alternate", false);
|
||||
radialMirrorButtonList.add(buttonRadialMirrorAlternate);
|
||||
|
||||
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(mc.player);
|
||||
@@ -180,8 +160,6 @@ public class RadialMirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
||||
buttonList.addAll(radialMirrorIconButtonList);
|
||||
|
||||
setCollapsed(!buttonRadialMirrorEnabled.isChecked());
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
public void updateScreen() {
|
||||
@@ -199,21 +177,21 @@ public class RadialMirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
||||
buttonRadialMirrorEnabled.render(mouseX, mouseY, partialTicks);
|
||||
if (buttonRadialMirrorEnabled.isChecked()) {
|
||||
buttonRadialMirrorEnabled.y = yy;
|
||||
fontRenderer.drawString("Radial mirror enabled", left + offset, yy + 2, 0xFFFFFF);
|
||||
font.drawString("Radial mirror enabled", left + offset, yy + 2, 0xFFFFFF);
|
||||
|
||||
yy = y + 18;
|
||||
fontRenderer.drawString("Position", left + offset, yy + 5, 0xFFFFFF);
|
||||
fontRenderer.drawString("X", left + 40 + offset, yy + 5, 0xFFFFFF);
|
||||
font.drawString("Position", left + offset, yy + 5, 0xFFFFFF);
|
||||
font.drawString("X", left + 40 + offset, yy + 5, 0xFFFFFF);
|
||||
textRadialMirrorPosX.y = yy;
|
||||
fontRenderer.drawString("Y", left + 120 + offset, yy + 5, 0xFFFFFF);
|
||||
font.drawString("Y", left + 120 + offset, yy + 5, 0xFFFFFF);
|
||||
textRadialMirrorPosY.y = yy;
|
||||
fontRenderer.drawString("Z", left + 200 + offset, yy + 5, 0xFFFFFF);
|
||||
font.drawString("Z", left + 200 + offset, yy + 5, 0xFFFFFF);
|
||||
textRadialMirrorPosZ.y = yy;
|
||||
|
||||
yy = y + 50;
|
||||
fontRenderer.drawString("Slices", left + offset, yy + 2, 0xFFFFFF);
|
||||
font.drawString("Slices", left + offset, yy + 2, 0xFFFFFF);
|
||||
textRadialMirrorSlices.y = yy - 3;
|
||||
fontRenderer.drawString("Radius", left + 176 + offset, yy + 2, 0xFFFFFF);
|
||||
font.drawString("Radius", left + 176 + offset, yy + 2, 0xFFFFFF);
|
||||
textRadialMirrorRadius.y = yy - 3;
|
||||
|
||||
yy = y + 72;
|
||||
@@ -231,12 +209,12 @@ public class RadialMirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
||||
.forEach(numberField -> numberField.drawNumberField(mouseX, mouseY, partialTicks));
|
||||
} else {
|
||||
buttonRadialMirrorEnabled.y = yy;
|
||||
fontRenderer.drawString("Radial mirror disabled", left + offset, yy + 2, 0x999999);
|
||||
font.drawString("Radial mirror disabled", left + offset, yy + 2, 0x999999);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void drawTooltip(GuiScreen guiScreen, int mouseX, int mouseY) {
|
||||
public void drawTooltip(Screen guiScreen, int mouseX, int mouseY) {
|
||||
//Draw tooltips last
|
||||
if (buttonRadialMirrorEnabled.isChecked())
|
||||
{
|
||||
@@ -261,7 +239,7 @@ public class RadialMirrorSettingsGui extends GuiCollapsibleScrollEntry {
|
||||
boolean insideRadialMirrorEnabledLabel = mouseX >= left && mouseX < right && relativeY >= -2 && relativeY < 12;
|
||||
|
||||
if (insideRadialMirrorEnabledLabel) {
|
||||
buttonRadialMirrorEnabled.playPressSound(this.mc.getSoundHandler());
|
||||
buttonRadialMirrorEnabled.playDownSound(this.mc.getSoundHandler());
|
||||
buttonRadialMirrorEnabled.onClick(mouseX, mouseY);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package nl.requios.effortlessbuilding.gui.elements;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraftforge.fml.client.config.GuiUtils;
|
||||
|
||||
/**
|
||||
* This class provides a checkbox style control.
|
||||
*/
|
||||
public class GuiCheckBoxFixed extends Button
|
||||
{
|
||||
private boolean isChecked;
|
||||
private int boxWidth;
|
||||
|
||||
public GuiCheckBoxFixed(int xPos, int yPos, String displayString, boolean isChecked)
|
||||
{
|
||||
super(xPos, yPos, Minecraft.getInstance().fontRenderer.getStringWidth(displayString) + 2 + 11, 11, displayString, b -> {});
|
||||
this.isChecked = isChecked;
|
||||
this.boxWidth = 11;
|
||||
this.height = 11;
|
||||
this.width = this.boxWidth + 2 + Minecraft.getInstance().fontRenderer.getStringWidth(displayString);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderButton(int mouseX, int mouseY, float partial)
|
||||
{
|
||||
if (this.visible)
|
||||
{
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
this.isHovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.boxWidth && mouseY < this.y + this.height;
|
||||
GuiUtils.drawContinuousTexturedBox(WIDGETS_LOCATION, this.x, this.y, 0, 46, this.boxWidth, this.height, 200, 20, 2, 3, 2, 2, this.blitOffset);
|
||||
this.renderBg(mc, mouseX, mouseY);
|
||||
int color = 14737632;
|
||||
|
||||
if (packedFGColor != 0)
|
||||
{
|
||||
color = packedFGColor;
|
||||
}
|
||||
else if (!this.active)
|
||||
{
|
||||
color = 10526880;
|
||||
}
|
||||
|
||||
if (this.isChecked)
|
||||
this.drawCenteredString(mc.fontRenderer, "x", this.x + this.boxWidth / 2 + 1, this.y + 1, 14737632);
|
||||
|
||||
this.drawString(mc.fontRenderer, getMessage(), this.x + this.boxWidth + 2, this.y + 2, color);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPress()
|
||||
{
|
||||
this.isChecked = !this.isChecked;
|
||||
}
|
||||
|
||||
public boolean isChecked()
|
||||
{
|
||||
return this.isChecked;
|
||||
}
|
||||
|
||||
public void setIsChecked(boolean isChecked)
|
||||
{
|
||||
this.isChecked = isChecked;
|
||||
}
|
||||
}
|
||||
@@ -2,20 +2,19 @@ package nl.requios.effortlessbuilding.gui.elements;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.IGuiEventListener;
|
||||
import net.minecraft.client.gui.widget.Widget;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public abstract class GuiCollapsibleScrollEntry implements GuiScrollPane.IScrollEntry {
|
||||
|
||||
public GuiScrollPane scrollPane;
|
||||
protected FontRenderer fontRenderer;
|
||||
protected FontRenderer font;
|
||||
protected Minecraft mc;
|
||||
|
||||
protected boolean isCollapsed = true;
|
||||
@@ -23,19 +22,16 @@ public abstract class GuiCollapsibleScrollEntry implements GuiScrollPane.IScroll
|
||||
|
||||
public GuiCollapsibleScrollEntry(GuiScrollPane scrollPane) {
|
||||
this.scrollPane = scrollPane;
|
||||
this.fontRenderer = scrollPane.fontRenderer;
|
||||
this.mc = scrollPane.parent.mc;
|
||||
this.font = scrollPane.font;
|
||||
this.mc = Minecraft.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int initGui(int id, List<GuiButton> buttonList) {
|
||||
|
||||
left = scrollPane.width / 2 - 140;
|
||||
right = scrollPane.width / 2 + 140;
|
||||
top = scrollPane.height / 2 - 100;
|
||||
bottom = scrollPane.height / 2 + 100;
|
||||
|
||||
return id;
|
||||
public void init(List<Widget> buttonList) {
|
||||
left = scrollPane.getWidth() / 2 - 140;
|
||||
right = scrollPane.getWidth() / 2 + 140;
|
||||
top = scrollPane.getHeight() / 2 - 100;
|
||||
bottom = scrollPane.getHeight() / 2 + 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,7 +39,7 @@ public abstract class GuiCollapsibleScrollEntry implements GuiScrollPane.IScroll
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTooltip(GuiScreen guiScreen, int mouseX, int mouseY) {
|
||||
public void drawTooltip(Screen guiScreen, int mouseX, int mouseY) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package nl.requios.effortlessbuilding.gui.elements;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@@ -12,19 +12,19 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class GuiIconButton extends GuiButton {
|
||||
public class GuiIconButton extends Button {
|
||||
|
||||
private final ResourceLocation resourceLocation;
|
||||
private final int iconX, iconY, iconWidth, iconHeight, iconAltX, iconAltY;
|
||||
List<String> tooltip = new ArrayList<>();
|
||||
private boolean useAltIcon = false;
|
||||
|
||||
public GuiIconButton(int buttonId, int x, int y, int iconX, int iconY, ResourceLocation resourceLocation) {
|
||||
this(buttonId, x, y, 20, 20, iconX, iconY, 20, 20, 20, 0, resourceLocation);
|
||||
public GuiIconButton(int x, int y, int iconX, int iconY, ResourceLocation resourceLocation, Button.IPressable onPress) {
|
||||
this(x, y, 20, 20, iconX, iconY, 20, 20, 20, 0, resourceLocation, onPress);
|
||||
}
|
||||
|
||||
public GuiIconButton(int buttonId, int x, int y, int width, int height, int iconX, int iconY, int iconWidth, int iconHeight, int iconAltX, int iconAltY, ResourceLocation resourceLocation) {
|
||||
super(buttonId, x, y, width, height, "");
|
||||
public GuiIconButton(int x, int y, int width, int height, int iconX, int iconY, int iconWidth, int iconHeight, int iconAltX, int iconAltY, ResourceLocation resourceLocation, Button.IPressable onPress) {
|
||||
super(x, y, width, height, "", onPress);
|
||||
this.iconX = iconX;
|
||||
this.iconY = iconY;
|
||||
this.iconWidth = iconWidth;
|
||||
@@ -51,7 +51,7 @@ public class GuiIconButton extends GuiButton {
|
||||
super.render(mouseX, mouseY, partialTicks);
|
||||
if (this.visible)
|
||||
{
|
||||
this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
|
||||
this.isHovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(this.resourceLocation);
|
||||
int currentIconX = this.iconX;
|
||||
int currentIconY = this.iconY;
|
||||
@@ -62,17 +62,18 @@ public class GuiIconButton extends GuiButton {
|
||||
currentIconY += iconAltY;
|
||||
}
|
||||
|
||||
this.drawTexturedModalRect(this.x, this.y, currentIconX, currentIconY, this.iconWidth, this.iconHeight);
|
||||
//Draws a textured rectangle at the current z-value. Used to be drawTexturedModalRect in Gui.
|
||||
this.blit(this.x, this.y, currentIconX, currentIconY, this.iconWidth, this.iconHeight);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawTooltip(GuiScreen guiScreen, int mouseX, int mouseY) {
|
||||
public void drawTooltip(Screen screen, int mouseX, int mouseY) {
|
||||
boolean flag = mouseX >= x && mouseX < x + width && mouseY >= y && mouseY < y + height;
|
||||
|
||||
if (flag) {
|
||||
List<String> textLines = new ArrayList<>();
|
||||
textLines.addAll(tooltip);
|
||||
guiScreen.drawHoveringText(textLines, mouseX - 10, mouseY + 25);
|
||||
screen.renderTooltip(textLines, mouseX - 10, mouseY + 25);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package nl.requios.effortlessbuilding.gui.elements;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.*;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.client.gui.widget.Widget;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
@@ -14,44 +16,37 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class GuiNumberField extends Gui {
|
||||
public class GuiNumberField extends AbstractGui {
|
||||
|
||||
public int x, y, width, height;
|
||||
public int buttonWidth = 10;
|
||||
|
||||
protected GuiTextField textField;
|
||||
protected GuiButton minusButton, plusButton;
|
||||
protected TextFieldWidget textField;
|
||||
protected Button minusButton, plusButton;
|
||||
|
||||
List<String> tooltip = new ArrayList<>();
|
||||
|
||||
public GuiNumberField(int id1, int id2, int id3, FontRenderer fontRenderer,
|
||||
List<GuiButton> buttonList, int x, int y, int width, int height) {
|
||||
public GuiNumberField(FontRenderer font, List<Widget> buttonList, int x, int y, int width, int height) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
|
||||
textField = new GuiTextField(id1, fontRenderer, x + buttonWidth + 1, y + 1, width - 2 * buttonWidth - 2, height - 2);
|
||||
minusButton = new GuiButton(id2, x, y - 1, buttonWidth, height + 2, "-") {
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
float valueChanged = 1f;
|
||||
if (GuiScreen.isCtrlKeyDown()) valueChanged = 5f;
|
||||
if (GuiScreen.isShiftKeyDown()) valueChanged = 10f;
|
||||
textField = new TextFieldWidget(font, x + buttonWidth + 1, y + 1, width - 2 * buttonWidth - 2, height - 2, "");
|
||||
minusButton = new Button(x, y - 1, buttonWidth, height + 2, "-", button -> {
|
||||
float valueChanged = 1f;
|
||||
if (Screen.hasControlDown()) valueChanged = 5f;
|
||||
if (Screen.hasShiftDown()) valueChanged = 10f;
|
||||
|
||||
setNumber(getNumber() - valueChanged);
|
||||
}
|
||||
};
|
||||
plusButton = new GuiButton(id3, x + width - buttonWidth, y - 1, buttonWidth, height + 2, "+") {
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
float valueChanged = 1f;
|
||||
if (GuiScreen.isCtrlKeyDown()) valueChanged = 5f;
|
||||
if (GuiScreen.isShiftKeyDown()) valueChanged = 10f;
|
||||
setNumber(getNumber() - valueChanged);
|
||||
});
|
||||
plusButton = new Button(x + width - buttonWidth, y - 1, buttonWidth, height + 2, "+", button -> {
|
||||
float valueChanged = 1f;
|
||||
if (Screen.hasControlDown()) valueChanged = 5f;
|
||||
if (Screen.hasShiftDown()) valueChanged = 10f;
|
||||
|
||||
setNumber(getNumber() + valueChanged);
|
||||
}
|
||||
};
|
||||
setNumber(getNumber() + valueChanged);
|
||||
});
|
||||
|
||||
buttonList.add(minusButton);
|
||||
buttonList.add(plusButton);
|
||||
@@ -87,7 +82,7 @@ public class GuiNumberField extends Gui {
|
||||
//Rightclicked inside textfield
|
||||
if (flag && mouseButton == 1) {
|
||||
textField.setText("");
|
||||
textField.setFocused(true);
|
||||
textField.setFocused2(true);
|
||||
result = true;
|
||||
}
|
||||
|
||||
@@ -99,12 +94,12 @@ public class GuiNumberField extends Gui {
|
||||
minusButton.y = y - 1;
|
||||
plusButton.y = y - 1;
|
||||
|
||||
textField.drawTextField(mouseX, mouseY, partialTicks);
|
||||
textField.render(mouseX, mouseY, partialTicks);
|
||||
minusButton.render(mouseX, mouseY, partialTicks);
|
||||
plusButton.render(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
public void drawTooltip(GuiScreen guiScreen, int mouseX, int mouseY) {
|
||||
public void drawTooltip(Screen screen, int mouseX, int mouseY) {
|
||||
boolean insideTextField = mouseX >= x + buttonWidth && mouseX < x + width - buttonWidth && mouseY >= y && mouseY < y + height;
|
||||
boolean insideMinusButton = mouseX >= x && mouseX < x + buttonWidth && mouseY >= y && mouseY < y + height;
|
||||
boolean insidePlusButton = mouseX >= x + width - buttonWidth && mouseX < x + width && mouseY >= y && mouseY < y + height;
|
||||
@@ -127,7 +122,7 @@ public class GuiNumberField extends Gui {
|
||||
textLines.add("Hold " + TextFormatting.AQUA + "ctrl " + TextFormatting.RESET + "for " + TextFormatting.DARK_GREEN + "5");
|
||||
}
|
||||
|
||||
guiScreen.drawHoveringText(textLines, mouseX - 10, mouseY + 25);
|
||||
screen.renderTooltip(textLines, mouseX - 10, mouseY + 25);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,43 +1,38 @@
|
||||
package nl.requios.effortlessbuilding.gui.elements;
|
||||
|
||||
import net.minecraft.client.MouseHelper;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.*;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.Widget;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import sun.security.ssl.Debug;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class GuiScrollPane extends GuiSlot {
|
||||
public class GuiScrollPane extends SlotGui {
|
||||
|
||||
public GuiScreen parent;
|
||||
public FontRenderer fontRenderer;
|
||||
public Screen parent;
|
||||
public FontRenderer font;
|
||||
private List<IScrollEntry> listEntries;
|
||||
private float scrollMultiplier = 1f;
|
||||
|
||||
private int mouseX;
|
||||
private int mouseY;
|
||||
|
||||
public GuiScrollPane(GuiScreen parent, FontRenderer fontRenderer, int top, int bottom) {
|
||||
super(parent.mc, parent.width, parent.height, top, bottom, 100);
|
||||
public GuiScrollPane(Screen parent, FontRenderer font, int top, int bottom) {
|
||||
super(Minecraft.getInstance(), parent.width, parent.height, top, bottom, 100);
|
||||
this.parent = parent;
|
||||
this.fontRenderer = fontRenderer;
|
||||
this.setShowSelectionBox(false);
|
||||
this.font = font;
|
||||
this.renderSelection = false;
|
||||
listEntries = new ArrayList<>();
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
@@ -51,131 +46,110 @@ public class GuiScrollPane extends GuiSlot {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSize() {
|
||||
protected int getItemCount() {
|
||||
return listEntries.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isSelected(int slotIndex) {
|
||||
protected boolean isSelectedItem(int slotIndex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getScrollBarX() {
|
||||
protected int getScrollbarPosition() {
|
||||
//return width / 2 + 140 + 10;
|
||||
return width - 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getListWidth() {
|
||||
public int getRowWidth() {
|
||||
return 280;
|
||||
}
|
||||
|
||||
//Removed background
|
||||
@Override
|
||||
public void drawScreen(int mouseXIn, int mouseYIn, float partialTicks)
|
||||
public void render(int mouseXIn, int mouseYIn, float partialTicks)
|
||||
{
|
||||
if (this.visible)
|
||||
{
|
||||
if (this.visible) {
|
||||
this.mouseX = mouseXIn;
|
||||
this.mouseY = mouseYIn;
|
||||
int scrollBarLeft = this.getScrollBarX();
|
||||
int scrollBarRight = scrollBarLeft + 6;
|
||||
this.bindAmountScrolled();
|
||||
this.renderBackground();
|
||||
int scrollbarLeft = this.getScrollbarPosition();
|
||||
int scrollbarRight = scrollbarLeft + 6;
|
||||
this.capYPosition();
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.disableFog();
|
||||
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder bufferbuilder = tessellator.getBuffer();
|
||||
int insideLeft = this.left + this.width / 2 - this.getListWidth() / 2 + 2;
|
||||
int insideTop = this.top + 4 - (int)this.amountScrolled;
|
||||
|
||||
if (this.hasListHeader) {
|
||||
this.drawListHeader(insideLeft, insideTop, tessellator);
|
||||
int insideLeft = this.x0 + this.width / 2 - this.getRowWidth() / 2 + 2;
|
||||
int insideTop = this.y0 + 4 - (int) this.yo;
|
||||
if (this.renderHeader) {
|
||||
this.renderHeader(insideLeft, insideTop, tessellator);
|
||||
}
|
||||
|
||||
//All entries
|
||||
this.drawSelectionBox(insideLeft, insideTop, mouseXIn, mouseYIn, partialTicks);
|
||||
this.renderList(insideLeft, insideTop, mouseXIn, mouseYIn, partialTicks);
|
||||
GlStateManager.disableDepthTest();
|
||||
|
||||
//Dirt overlays on top and bottom
|
||||
// this.overlayBackground(0, this.top, 255, 255);
|
||||
// this.overlayBackground(this.bottom, this.height, 255, 255);
|
||||
// this.renderHoleBackground(0, this.y0, 255, 255);
|
||||
// this.renderHoleBackground(this.y1, this.height, 255, 255);
|
||||
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ZERO, GlStateManager.DestFactor.ONE);
|
||||
GlStateManager.disableAlphaTest();
|
||||
GlStateManager.shadeModel(7425);
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.disableTexture();
|
||||
|
||||
// //top fade
|
||||
//top
|
||||
// bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
||||
// bufferbuilder.pos((double)this.left, (double)(this.top + 5), 0.0D).tex(0.0D, 1.0D).color(100, 100, 100, 0).endVertex();
|
||||
// bufferbuilder.pos((double)this.right, (double)(this.top + 5), 0.0D).tex(1.0D, 1.0D).color(100, 100, 100, 0).endVertex();
|
||||
// bufferbuilder.pos((double)this.right, (double)this.top, 0.0D).tex(1.0D, 0.0D).color(100, 100, 100, 100).endVertex();
|
||||
// bufferbuilder.pos((double)this.left, (double)this.top, 0.0D).tex(0.0D, 0.0D).color(100, 100, 100, 100).endVertex();
|
||||
// bufferbuilder.pos((double)this.x0, (double)(this.y0 + 4), 0.0D).tex(0.0D, 1.0D).color(0, 0, 0, 0).endVertex();
|
||||
// bufferbuilder.pos((double)this.x1, (double)(this.y0 + 4), 0.0D).tex(1.0D, 1.0D).color(0, 0, 0, 0).endVertex();
|
||||
// bufferbuilder.pos((double)this.x1, (double)this.y0, 0.0D).tex(1.0D, 0.0D).color(0, 0, 0, 255).endVertex();
|
||||
// bufferbuilder.pos((double)this.x0, (double)this.y0, 0.0D).tex(0.0D, 0.0D).color(0, 0, 0, 255).endVertex();
|
||||
// tessellator.draw();
|
||||
|
||||
// //top line
|
||||
//bottom
|
||||
// bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
||||
// bufferbuilder.pos((double)this.left, (double)this.top, 0.0D).tex(0.0D, 1.0D).color(20, 20, 20, 255).endVertex();
|
||||
// bufferbuilder.pos((double)this.right, (double)this.top, 0.0D).tex(1.0D, 1.0D).color(20, 20, 20, 255).endVertex();
|
||||
// bufferbuilder.pos((double)this.right, (double)(this.top - 1), 0.0D).tex(1.0D, 0.0D).color(20, 20, 20, 255).endVertex();
|
||||
// bufferbuilder.pos((double)this.left, (double)(this.top - 1), 0.0D).tex(0.0D, 0.0D).color(20, 20, 20, 255).endVertex();
|
||||
// tessellator.draw();
|
||||
|
||||
// //bottom fade
|
||||
// bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
||||
// bufferbuilder.pos((double)this.left, (double)this.bottom, 0.0D).tex(0.0D, 1.0D).color(10, 10, 10, 100).endVertex();
|
||||
// bufferbuilder.pos((double)this.right, (double)this.bottom, 0.0D).tex(1.0D, 1.0D).color(10, 10, 10, 100).endVertex();
|
||||
// bufferbuilder.pos((double)this.right, (double)(this.bottom - 5), 0.0D).tex(1.0D, 0.0D).color(10, 10, 10, 0).endVertex();
|
||||
// bufferbuilder.pos((double)this.left, (double)(this.bottom - 5), 0.0D).tex(0.0D, 0.0D).color(10, 10, 10, 0).endVertex();
|
||||
// tessellator.draw();
|
||||
|
||||
// //bottom line
|
||||
// bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
||||
// bufferbuilder.pos((double)this.left, (double)(this.bottom + 1), 0.0D).tex(0.0D, 1.0D).color(20, 20, 20, 255).endVertex();
|
||||
// bufferbuilder.pos((double)this.right, (double)(this.bottom + 1), 0.0D).tex(1.0D, 1.0D).color(20, 20, 20, 255).endVertex();
|
||||
// bufferbuilder.pos((double)this.right, (double)this.bottom, 0.0D).tex(1.0D, 0.0D).color(20, 20, 20, 255).endVertex();
|
||||
// bufferbuilder.pos((double)this.left, (double)this.bottom, 0.0D).tex(0.0D, 0.0D).color(20, 20, 20, 255).endVertex();
|
||||
// bufferbuilder.pos((double)this.x0, (double)this.y1, 0.0D).tex(0.0D, 1.0D).color(0, 0, 0, 255).endVertex();
|
||||
// bufferbuilder.pos((double)this.x1, (double)this.y1, 0.0D).tex(1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
|
||||
// bufferbuilder.pos((double)this.x1, (double)(this.y1 - 4), 0.0D).tex(1.0D, 0.0D).color(0, 0, 0, 0).endVertex();
|
||||
// bufferbuilder.pos((double)this.x0, (double)(this.y1 - 4), 0.0D).tex(0.0D, 0.0D).color(0, 0, 0, 0).endVertex();
|
||||
// tessellator.draw();
|
||||
|
||||
//Draw scrollbar
|
||||
int maxScroll = this.getMaxScroll();
|
||||
if (maxScroll > 0)
|
||||
{
|
||||
int k1 = (this.bottom - this.top) * (this.bottom - this.top) / this.getContentHeight();
|
||||
k1 = MathHelper.clamp(k1, 32, this.bottom - this.top - 8);
|
||||
int l1 = (int)this.amountScrolled * (this.bottom - this.top - k1) / maxScroll + this.top;
|
||||
|
||||
if (l1 < this.top)
|
||||
{
|
||||
l1 = this.top;
|
||||
if (maxScroll > 0) {
|
||||
int k1 = (int) ((float) ((this.y1 - this.y0) * (this.y1 - this.y0)) / (float) this.getMaxPosition());
|
||||
k1 = MathHelper.clamp(k1, 32, this.y1 - this.y0 - 8);
|
||||
int l1 = (int) this.yo * (this.y1 - this.y0 - k1) / maxScroll + this.y0;
|
||||
if (l1 < this.y0) {
|
||||
l1 = this.y0;
|
||||
}
|
||||
|
||||
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
||||
bufferbuilder.pos((double)scrollBarLeft, (double)this.bottom, 0.0D).tex(0.0D, 1.0D).color(0, 0, 0, 255).endVertex();
|
||||
bufferbuilder.pos((double)scrollBarRight, (double)this.bottom, 0.0D).tex(1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
|
||||
bufferbuilder.pos((double)scrollBarRight, (double)this.top, 0.0D).tex(1.0D, 0.0D).color(0, 0, 0, 255).endVertex();
|
||||
bufferbuilder.pos((double)scrollBarLeft, (double)this.top, 0.0D).tex(0.0D, 0.0D).color(0, 0, 0, 255).endVertex();
|
||||
bufferbuilder.pos((double) scrollbarLeft, (double) this.y1, 0.0D).tex(0.0D, 1.0D).color(0, 0, 0, 255).endVertex();
|
||||
bufferbuilder.pos((double) scrollbarRight, (double) this.y1, 0.0D).tex(1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
|
||||
bufferbuilder.pos((double) scrollbarRight, (double) this.y0, 0.0D).tex(1.0D, 0.0D).color(0, 0, 0, 255).endVertex();
|
||||
bufferbuilder.pos((double) scrollbarLeft, (double) this.y0, 0.0D).tex(0.0D, 0.0D).color(0, 0, 0, 255).endVertex();
|
||||
tessellator.draw();
|
||||
|
||||
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
||||
bufferbuilder.pos((double)scrollBarLeft, (double)(l1 + k1), 0.0D).tex(0.0D, 1.0D).color(128, 128, 128, 255).endVertex();
|
||||
bufferbuilder.pos((double)scrollBarRight, (double)(l1 + k1), 0.0D).tex(1.0D, 1.0D).color(128, 128, 128, 255).endVertex();
|
||||
bufferbuilder.pos((double)scrollBarRight, (double)l1, 0.0D).tex(1.0D, 0.0D).color(128, 128, 128, 255).endVertex();
|
||||
bufferbuilder.pos((double)scrollBarLeft, (double)l1, 0.0D).tex(0.0D, 0.0D).color(128, 128, 128, 255).endVertex();
|
||||
bufferbuilder.pos((double) scrollbarLeft, (double) (l1 + k1), 0.0D).tex(0.0D, 1.0D).color(128, 128, 128, 255).endVertex();
|
||||
bufferbuilder.pos((double) scrollbarRight, (double) (l1 + k1), 0.0D).tex(1.0D, 1.0D).color(128, 128, 128, 255).endVertex();
|
||||
bufferbuilder.pos((double) scrollbarRight, (double) l1, 0.0D).tex(1.0D, 0.0D).color(128, 128, 128, 255).endVertex();
|
||||
bufferbuilder.pos((double) scrollbarLeft, (double) l1, 0.0D).tex(0.0D, 0.0D).color(128, 128, 128, 255).endVertex();
|
||||
tessellator.draw();
|
||||
|
||||
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
||||
bufferbuilder.pos((double)scrollBarLeft, (double)(l1 + k1 - 1), 0.0D).tex(0.0D, 1.0D).color(192, 192, 192, 255).endVertex();
|
||||
bufferbuilder.pos((double)(scrollBarRight - 1), (double)(l1 + k1 - 1), 0.0D).tex(1.0D, 1.0D).color(192, 192, 192, 255).endVertex();
|
||||
bufferbuilder.pos((double)(scrollBarRight - 1), (double)l1, 0.0D).tex(1.0D, 0.0D).color(192, 192, 192, 255).endVertex();
|
||||
bufferbuilder.pos((double)scrollBarLeft, (double)l1, 0.0D).tex(0.0D, 0.0D).color(192, 192, 192, 255).endVertex();
|
||||
bufferbuilder.pos((double) scrollbarLeft, (double) (l1 + k1 - 1), 0.0D).tex(0.0D, 1.0D).color(192, 192, 192, 255).endVertex();
|
||||
bufferbuilder.pos((double) (scrollbarRight - 1), (double) (l1 + k1 - 1), 0.0D).tex(1.0D, 1.0D).color(192, 192, 192, 255).endVertex();
|
||||
bufferbuilder.pos((double) (scrollbarRight - 1), (double) l1, 0.0D).tex(1.0D, 0.0D).color(192, 192, 192, 255).endVertex();
|
||||
bufferbuilder.pos((double) scrollbarLeft, (double) l1, 0.0D).tex(0.0D, 0.0D).color(192, 192, 192, 255).endVertex();
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
GlStateManager.enableTexture2D();
|
||||
GlStateManager.enableTexture();
|
||||
GlStateManager.shadeModel(7424);
|
||||
GlStateManager.enableAlphaTest();
|
||||
GlStateManager.disableBlend();
|
||||
@@ -185,9 +159,9 @@ public class GuiScrollPane extends GuiSlot {
|
||||
//SLOTHEIGHT MODIFICATIONS
|
||||
//SlotHeight is still relied on for determining how much to scroll
|
||||
@Override
|
||||
protected int getContentHeight() {
|
||||
protected int getMaxPosition() {
|
||||
//Add every entry height
|
||||
int height = this.headerPadding;
|
||||
int height = this.headerHeight;
|
||||
for (IScrollEntry entry : listEntries) {
|
||||
height += entry.getHeight();
|
||||
}
|
||||
@@ -195,19 +169,19 @@ public class GuiScrollPane extends GuiSlot {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawBackground() {
|
||||
protected void renderBackground() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawSlot(int slotIndex, int xPos, int yPos, int heightIn, int mouseXIn, int mouseYIn, float partialTicks) {
|
||||
this.getListEntry(slotIndex).drawEntry(slotIndex, xPos, yPos, this.getListWidth(), heightIn, mouseXIn, mouseYIn,
|
||||
protected void renderItem(int slotIndex, int xPos, int yPos, int heightIn, int mouseXIn, int mouseYIn, float partialTicks) {
|
||||
this.getListEntry(slotIndex).drawEntry(slotIndex, xPos, yPos, this.getRowWidth(), heightIn, mouseXIn, mouseYIn,
|
||||
this.getSlotIndexFromScreenCoords(mouseXIn, mouseYIn) == slotIndex, partialTicks);
|
||||
}
|
||||
|
||||
public int getContentHeight(int count) {
|
||||
public int getMaxPosition(int count) {
|
||||
//Add all count entry heights
|
||||
int height = this.headerPadding;
|
||||
int height = this.headerHeight;
|
||||
for (int i = 0; i < count; i++) {
|
||||
IScrollEntry entry = listEntries.get(i);
|
||||
height += entry.getHeight();
|
||||
@@ -216,23 +190,23 @@ public class GuiScrollPane extends GuiSlot {
|
||||
}
|
||||
|
||||
public int getSlotIndexFromScreenCoords(double posX, double posY) {
|
||||
int left = this.left + (this.width - this.getListWidth()) / 2;
|
||||
int right = this.left + (this.width + this.getListWidth()) / 2;
|
||||
int left = this.x0 + (this.width - this.getRowWidth()) / 2;
|
||||
int right = this.x0 + (this.width + this.getRowWidth()) / 2;
|
||||
double relativeMouseY = getRelativeMouseY(mouseY, 0);
|
||||
|
||||
//Iterate over every entry until relativeMouseY falls within its height
|
||||
for (int i = 0; i < listEntries.size(); i++) {
|
||||
IScrollEntry entry = listEntries.get(i);
|
||||
if (relativeMouseY <= entry.getHeight())
|
||||
return posX < this.getScrollBarX() && posX >= left && posX <= right && i >= 0 &&
|
||||
relativeMouseY >= 0 && i < this.getSize() ? i : -1;
|
||||
return posX < this.getScrollbarPosition() && posX >= left && posX <= right && i >= 0 &&
|
||||
relativeMouseY >= 0 && i < this.getItemCount() ? i : -1;
|
||||
relativeMouseY -= entry.getHeight();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean mouseClicked(int index, int button, double mouseX, double mouseY) {
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||
int selectedSlot = this.getSlotIndexFromScreenCoords(mouseX, mouseY);
|
||||
double relativeX = getRelativeMouseX(mouseX);
|
||||
|
||||
@@ -264,12 +238,12 @@ public class GuiScrollPane extends GuiSlot {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseReleased(double p_mouseReleased_1_, double p_mouseReleased_3_, int p_mouseReleased_5_) {
|
||||
for (int i = 0; i < this.getSize(); ++i)
|
||||
public boolean mouseReleased(double mouseX, double mouseY, int button) {
|
||||
for (int i = 0; i < this.getItemCount(); ++i)
|
||||
{
|
||||
double relativeX = getRelativeMouseX(mouseX);
|
||||
double relativeY = getRelativeMouseY(mouseY, i);
|
||||
this.getListEntry(i).mouseReleased(i, (int) p_mouseReleased_1_, (int) p_mouseReleased_3_, p_mouseReleased_5_, (int) relativeX, (int) relativeY);
|
||||
this.getListEntry(i).mouseReleased(i, (int) mouseX, (int) mouseY, button, (int) relativeX, (int) relativeY);
|
||||
}
|
||||
|
||||
this.visible = true;
|
||||
@@ -278,45 +252,39 @@ public class GuiScrollPane extends GuiSlot {
|
||||
|
||||
public void handleMouseInput() {
|
||||
if (this.isMouseInList(this.mouseX, this.mouseY)) {
|
||||
if (mc.mouseHelper.isLeftDown() && this.mouseY >= this.top &&
|
||||
this.mouseY <= this.bottom) {
|
||||
int i = this.left + (this.width - this.getListWidth()) / 2;
|
||||
int j = this.left + (this.width + this.getListWidth()) / 2;
|
||||
if (minecraft.mouseHelper.isLeftDown() && this.mouseY >= this.y0 &&
|
||||
this.mouseY <= this.y1) {
|
||||
int i = this.x0 + (this.width - this.getRowWidth()) / 2;
|
||||
int j = this.x0 + (this.width + this.getRowWidth()) / 2;
|
||||
int slotIndex = getSlotIndexFromScreenCoords(this.mouseX, this.mouseY);
|
||||
double relativeMouseY = getRelativeMouseY(mouseY, slotIndex);
|
||||
|
||||
if (slotIndex > -1) {
|
||||
this.mouseClicked(slotIndex, 0, this.mouseX, this.mouseY);
|
||||
this.selectedElement = slotIndex;
|
||||
this.mouseClicked(this.mouseX, this.mouseY, 0);
|
||||
} else if (this.mouseX >= i && this.mouseX <= j && relativeMouseY < 0) {
|
||||
this.clickedHeader(this.mouseX - i, this.mouseY - this.top + (int) this.amountScrolled - 4);
|
||||
this.clickedHeader(this.mouseX - i, this.mouseY - this.y0 + (int) this.yo - 4);
|
||||
}
|
||||
}
|
||||
|
||||
if (mc.mouseHelper.isLeftDown() && this.isVisible()) {
|
||||
if (this.initialClickY == -1) {
|
||||
if (minecraft.mouseHelper.isLeftDown() && this.isVisible()) {
|
||||
if (this.yDrag == -1) {
|
||||
boolean flag1 = true;
|
||||
|
||||
if (this.mouseY >= this.top && this.mouseY <= this.bottom) {
|
||||
int i2 = this.left + (this.width - this.getListWidth()) / 2;
|
||||
int j2 = this.left + (this.width + this.getListWidth()) / 2;
|
||||
if (this.mouseY >= this.y0 && this.mouseY <= this.y1) {
|
||||
int i2 = this.x0 + (this.width - this.getRowWidth()) / 2;
|
||||
int j2 = this.x0 + (this.width + this.getRowWidth()) / 2;
|
||||
int slotIndex = getSlotIndexFromScreenCoords(this.mouseX, this.mouseY);
|
||||
double relativeMouseY = getRelativeMouseY(mouseY, slotIndex);
|
||||
|
||||
if (slotIndex > -1) {
|
||||
//TODO 1.13 use flag
|
||||
boolean flag = slotIndex == this.selectedElement &&
|
||||
Util.milliTime() - this.lastClicked < 250L;
|
||||
this.mouseClicked(slotIndex, this.mouseX, this.mouseY);
|
||||
this.selectedElement = slotIndex;
|
||||
this.lastClicked = Util.milliTime();
|
||||
} else if (this.mouseX >= i2 && this.mouseX <= j2 && relativeMouseY < 0) {
|
||||
this.clickedHeader(this.mouseX - i2,
|
||||
this.mouseY - this.top + (int) this.amountScrolled - 4);
|
||||
this.mouseY - this.y0 + (int) this.yo - 4);
|
||||
flag1 = false;
|
||||
}
|
||||
|
||||
int i3 = this.getScrollBarX();
|
||||
int i3 = this.getScrollbarPosition();
|
||||
int j1 = i3 + 6;
|
||||
|
||||
if (this.mouseX >= i3 && this.mouseX <= j1) {
|
||||
@@ -327,60 +295,45 @@ public class GuiScrollPane extends GuiSlot {
|
||||
maxScroll = 1;
|
||||
}
|
||||
|
||||
int l1 = (int) ((float) ((this.bottom - this.top) * (this.bottom - this.top)) /
|
||||
(float) this.getContentHeight());
|
||||
l1 = MathHelper.clamp(l1, 32, this.bottom - this.top - 8);
|
||||
this.scrollMultiplier /= (float) (this.bottom - this.top - l1) / (float) maxScroll;
|
||||
int l1 = (int) ((float) ((this.y1 - this.y0) * (this.y1 - this.y0)) /
|
||||
(float) this.getMaxPosition());
|
||||
l1 = MathHelper.clamp(l1, 32, this.y1 - this.y0 - 8);
|
||||
this.scrollMultiplier /= (float) (this.y1 - this.y0 - l1) / (float) maxScroll;
|
||||
} else {
|
||||
this.scrollMultiplier = 1.0F;
|
||||
}
|
||||
|
||||
if (flag1) {
|
||||
this.initialClickY = this.mouseY;
|
||||
this.yDrag = this.mouseY;
|
||||
} else {
|
||||
this.initialClickY = -2;
|
||||
this.yDrag = -2;
|
||||
}
|
||||
} else {
|
||||
this.initialClickY = -2;
|
||||
this.yDrag = -2;
|
||||
}
|
||||
} else if (this.initialClickY >= 0) {
|
||||
this.amountScrolled -= (float) (this.mouseY - this.initialClickY) * this.scrollMultiplier;
|
||||
this.initialClickY = this.mouseY;
|
||||
} else if (this.yDrag >= 0) {
|
||||
this.yo -= (float) (this.mouseY - this.yDrag) * this.scrollMultiplier;
|
||||
this.yDrag = this.mouseY;
|
||||
}
|
||||
} else {
|
||||
this.initialClickY = -1;
|
||||
this.yDrag = -1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Through forge event instead of through the parent, because the parent no longer has scroll functionality in 1.13
|
||||
@SubscribeEvent
|
||||
public void mouseScrolled(GuiScreenEvent.MouseScrollEvent.Pre event) {
|
||||
double scrollDelta = event.getScrollDelta();
|
||||
if (scrollDelta != 0) {
|
||||
if (scrollDelta > 0) {
|
||||
scrollDelta = -1;
|
||||
} else if (scrollDelta < 0) {
|
||||
scrollDelta = 1;
|
||||
}
|
||||
|
||||
this.amountScrolled += (float) (scrollDelta * this.slotHeight / 2);
|
||||
}
|
||||
}
|
||||
|
||||
//Draw in center if it fits
|
||||
@Override
|
||||
protected void drawSelectionBox(int insideLeft, int insideTop, int mouseXIn, int mouseYIn, float partialTicks)
|
||||
protected void renderList(int insideLeft, int insideTop, int mouseXIn, int mouseYIn, float partialTicks)
|
||||
{
|
||||
int size = this.getSize();
|
||||
int itemCount = this.getItemCount();
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder bufferbuilder = tessellator.getBuffer();
|
||||
|
||||
//Find y to start with
|
||||
int y = this.headerPadding + insideTop;
|
||||
int contentHeight = getContentHeight();
|
||||
int insideHeight = this.bottom - this.top - 4;
|
||||
int y = this.headerHeight + insideTop;
|
||||
int contentHeight = getMaxPosition();
|
||||
int insideHeight = this.y1 - this.y0 - 4;
|
||||
|
||||
if (contentHeight < insideHeight) {
|
||||
//it fits, so we can center it vertically
|
||||
@@ -388,66 +341,68 @@ public class GuiScrollPane extends GuiSlot {
|
||||
}
|
||||
|
||||
//Draw all entries
|
||||
for (int i = 0; i < size; ++i)
|
||||
for (int i = 0; i < itemCount; ++i)
|
||||
{
|
||||
int entryHeight = listEntries.get(i).getHeight();
|
||||
int entryHeight2 = entryHeight - 4;
|
||||
|
||||
if (y > this.bottom || y + entryHeight2 < this.top)
|
||||
if (y > this.y1 || y + entryHeight2 < this.y0)
|
||||
{
|
||||
this.updateItemPos(i, insideLeft, y, partialTicks);
|
||||
this.updateItemPosition(i, insideLeft, y, partialTicks);
|
||||
}
|
||||
|
||||
if (this.showSelectionBox && this.isSelected(i))
|
||||
{
|
||||
int i1 = this.left + this.width / 2 - this.getListWidth() / 2;
|
||||
int j1 = this.left + this.width / 2 + this.getListWidth() / 2;
|
||||
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GlStateManager.disableTexture2D();
|
||||
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
||||
bufferbuilder.pos((double)i1, (double)(y + entryHeight2 + 2), 0.0D).tex(0.0D, 1.0D).color(128, 128, 128, 255).endVertex();
|
||||
bufferbuilder.pos((double)j1, (double)(y + entryHeight2 + 2), 0.0D).tex(1.0D, 1.0D).color(128, 128, 128, 255).endVertex();
|
||||
bufferbuilder.pos((double)j1, (double)(y - 2), 0.0D).tex(1.0D, 0.0D).color(128, 128, 128, 255).endVertex();
|
||||
bufferbuilder.pos((double)i1, (double)(y - 2), 0.0D).tex(0.0D, 0.0D).color(128, 128, 128, 255).endVertex();
|
||||
bufferbuilder.pos((double)(i1 + 1), (double)(y + entryHeight2 + 1), 0.0D).tex(0.0D, 1.0D).color(0, 0, 0, 255).endVertex();
|
||||
bufferbuilder.pos((double)(j1 - 1), (double)(y + entryHeight2 + 1), 0.0D).tex(1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
|
||||
bufferbuilder.pos((double)(j1 - 1), (double)(y - 1), 0.0D).tex(1.0D, 0.0D).color(0, 0, 0, 255).endVertex();
|
||||
bufferbuilder.pos((double)(i1 + 1), (double)(y - 1), 0.0D).tex(0.0D, 0.0D).color(0, 0, 0, 255).endVertex();
|
||||
if (this.renderSelection && this.isSelectedItem(i)) {
|
||||
int i1 = this.x0 + this.width / 2 - this.getRowWidth() / 2;
|
||||
int j1 = this.x0 + this.width / 2 + this.getRowWidth() / 2;
|
||||
GlStateManager.disableTexture();
|
||||
float f = this.isFocused() ? 1.0F : 0.5F;
|
||||
GlStateManager.color4f(f, f, f, 1.0F);
|
||||
bufferbuilder.begin(7, DefaultVertexFormats.POSITION);
|
||||
bufferbuilder.pos((double)i1, (double)(y + entryHeight2 + 2), 0.0D).endVertex();
|
||||
bufferbuilder.pos((double)j1, (double)(y + entryHeight2 + 2), 0.0D).endVertex();
|
||||
bufferbuilder.pos((double)j1, (double)(y - 2), 0.0D).endVertex();
|
||||
bufferbuilder.pos((double)i1, (double)(y - 2), 0.0D).endVertex();
|
||||
tessellator.draw();
|
||||
GlStateManager.enableTexture2D();
|
||||
GlStateManager.color4f(0.0F, 0.0F, 0.0F, 1.0F);
|
||||
bufferbuilder.begin(7, DefaultVertexFormats.POSITION);
|
||||
bufferbuilder.pos((double)(i1 + 1), (double)(y + entryHeight2 + 1), 0.0D).endVertex();
|
||||
bufferbuilder.pos((double)(j1 - 1), (double)(y + entryHeight2 + 1), 0.0D).endVertex();
|
||||
bufferbuilder.pos((double)(j1 - 1), (double)(y - 1), 0.0D).endVertex();
|
||||
bufferbuilder.pos((double)(i1 + 1), (double)(y - 1), 0.0D).endVertex();
|
||||
tessellator.draw();
|
||||
GlStateManager.enableTexture();
|
||||
}
|
||||
|
||||
this.drawSlot(i, insideLeft, y, entryHeight2, mouseXIn, mouseYIn, partialTicks);
|
||||
this.renderItem(i, insideLeft, y, entryHeight2, mouseXIn, mouseYIn, partialTicks);
|
||||
y += entryHeight;
|
||||
}
|
||||
}
|
||||
|
||||
private double getRelativeMouseX(double mouseX) {
|
||||
int j = this.left + this.width / 2 - this.getListWidth() / 2 + 2;
|
||||
int j = this.x0 + this.width / 2 - this.getRowWidth() / 2 + 2;
|
||||
return mouseX - j;
|
||||
}
|
||||
|
||||
private double getRelativeMouseY(double mouseY, int contentIndex) {
|
||||
int k = this.top + 4 - this.getAmountScrolled() + getContentHeight(contentIndex) + this.headerPadding;
|
||||
int k = this.y0 + 4 - this.getScroll() + getMaxPosition(contentIndex) + this.headerHeight;
|
||||
double relativeMouseY = mouseY - k;
|
||||
|
||||
//Content might be centered, adjust relative mouse y accordingly
|
||||
int contentHeight = getContentHeight();
|
||||
int insideHeight = this.bottom - this.top - 4;
|
||||
int contentHeight = getMaxPosition();
|
||||
int insideHeight = this.y1 - this.y0 - 4;
|
||||
|
||||
if (contentHeight < insideHeight) {
|
||||
//it fits, so we can center it vertically
|
||||
relativeMouseY -= (insideHeight - contentHeight) / 2;
|
||||
relativeMouseY -= (insideHeight - contentHeight) / 2f;
|
||||
}
|
||||
return relativeMouseY;
|
||||
}
|
||||
|
||||
//PASSTHROUGHS
|
||||
public int initGui(int id, List<GuiButton> buttonList) {
|
||||
public void init(List<Widget> buttonList) {
|
||||
for (IScrollEntry entry : this.listEntries) {
|
||||
id = entry.initGui(id, buttonList);
|
||||
entry.init(buttonList);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
public void updateScreen() {
|
||||
@@ -455,7 +410,7 @@ public class GuiScrollPane extends GuiSlot {
|
||||
entry.updateScreen();
|
||||
}
|
||||
|
||||
public void drawTooltip(GuiScreen guiScreen, int mouseX, int mouseY) {
|
||||
public void drawTooltip(Screen guiScreen, int mouseX, int mouseY) {
|
||||
for (IScrollEntry entry : this.listEntries)
|
||||
entry.drawTooltip(guiScreen, mouseX, mouseY);
|
||||
}
|
||||
@@ -472,12 +427,21 @@ public class GuiScrollPane extends GuiSlot {
|
||||
entry.onGuiClosed();
|
||||
}
|
||||
|
||||
//Make protected values available
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public interface IScrollEntry {
|
||||
int initGui(int id, List<GuiButton> buttonList);
|
||||
void init(List<Widget> buttonList);
|
||||
|
||||
void updateScreen();
|
||||
|
||||
void drawTooltip(GuiScreen guiScreen, int mouseX, int mouseY);
|
||||
void drawTooltip(Screen guiScreen, int mouseX, int mouseY);
|
||||
|
||||
boolean charTyped(char eventChar, int eventKey);
|
||||
|
||||
|
||||
@@ -1,28 +1,27 @@
|
||||
package nl.requios.effortlessbuilding.helper;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class InventoryHelper {
|
||||
|
||||
public static ItemStack findItemStackInInventory(EntityPlayer player, Block block) {
|
||||
public static ItemStack findItemStackInInventory(PlayerEntity player, Block block) {
|
||||
for (ItemStack invStack : player.inventory.mainInventory) {
|
||||
if (!invStack.isEmpty() && invStack.getItem() instanceof ItemBlock &&
|
||||
((ItemBlock) invStack.getItem()).getBlock().equals(block)) {
|
||||
if (!invStack.isEmpty() && invStack.getItem() instanceof BlockItem &&
|
||||
((BlockItem) invStack.getItem()).getBlock().equals(block)) {
|
||||
return invStack;
|
||||
}
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
public static int findTotalBlocksInInventory(EntityPlayer player, Block block) {
|
||||
public static int findTotalBlocksInInventory(PlayerEntity player, Block block) {
|
||||
int total = 0;
|
||||
for (ItemStack invStack : player.inventory.mainInventory) {
|
||||
if (!invStack.isEmpty() && invStack.getItem() instanceof ItemBlock &&
|
||||
((ItemBlock) invStack.getItem()).getBlock().equals(block)) {
|
||||
if (!invStack.isEmpty() && invStack.getItem() instanceof BlockItem &&
|
||||
((BlockItem) invStack.getItem()).getBlock().equals(block)) {
|
||||
total += invStack.getCount();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package nl.requios.effortlessbuilding.helper;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraftforge.common.crafting.IConditionSerializer;
|
||||
import nl.requios.effortlessbuilding.BuildConfig;
|
||||
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
public class ReachConditionFactory implements IConditionSerializer {
|
||||
@Override
|
||||
public BooleanSupplier parse(JsonObject json) {
|
||||
return () -> BuildConfig.reach.enableReachUpgrades.get();
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
package nl.requios.effortlessbuilding.helper;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import nl.requios.effortlessbuilding.BuildConfig;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
|
||||
|
||||
public class ReachHelper {
|
||||
public static int getMaxReach(EntityPlayer player) {
|
||||
public static int getMaxReach(PlayerEntity player) {
|
||||
if (player.isCreative()) return BuildConfig.reach.maxReachCreative.get();
|
||||
|
||||
if (!BuildConfig.reach.enableReachUpgrades.get()) return BuildConfig.reach.maxReachLevel3.get();
|
||||
@@ -22,11 +22,11 @@ public class ReachHelper {
|
||||
return BuildConfig.reach.maxReachLevel0.get();
|
||||
}
|
||||
|
||||
public static int getPlacementReach(EntityPlayer player) {
|
||||
public static int getPlacementReach(PlayerEntity player) {
|
||||
return getMaxReach(player) / 4;
|
||||
}
|
||||
|
||||
public static int getMaxBlocksPlacedAtOnce(EntityPlayer player) {
|
||||
public static int getMaxBlocksPlacedAtOnce(PlayerEntity player) {
|
||||
if (player.isCreative()) return 1000000;
|
||||
return MathHelper.ceil(Math.pow(getMaxReach(player), 1.6));
|
||||
//Level 0: 121
|
||||
@@ -35,7 +35,7 @@ public class ReachHelper {
|
||||
//Level 3: 4805
|
||||
}
|
||||
|
||||
public static int getMaxBlocksPerAxis(EntityPlayer player) {
|
||||
public static int getMaxBlocksPerAxis(PlayerEntity player) {
|
||||
if (player.isCreative()) return 2000;
|
||||
return MathHelper.ceil(getMaxReach(player) * 0.3);
|
||||
//Level 0: 6
|
||||
@@ -44,7 +44,7 @@ public class ReachHelper {
|
||||
//Level 3: 60
|
||||
}
|
||||
|
||||
public static boolean canBreakFar(EntityPlayer player) {
|
||||
public static boolean canBreakFar(PlayerEntity player) {
|
||||
return player.isCreative() || BuildConfig.survivalBalancers.breakFar.get();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,24 @@
|
||||
package nl.requios.effortlessbuilding.helper;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockSlab;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.SlabBlock;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.BlockWorldState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.CachedBlockInfo;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import nl.requios.effortlessbuilding.BuildConfig;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
|
||||
import nl.requios.effortlessbuilding.compatibility.CompatHelper;
|
||||
|
||||
@@ -34,15 +30,15 @@ public class SurvivalHelper {
|
||||
//Used for all placing of blocks in this mod.
|
||||
//Checks if area is loaded, if player has the right permissions, if existing block can be replaced (drops it if so) and consumes an item from the stack.
|
||||
//Based on ItemBlock#onItemUse
|
||||
public static boolean placeBlock(World world, EntityPlayer player, BlockPos pos, IBlockState blockState,
|
||||
ItemStack origstack, EnumFacing facing, Vec3d hitVec, boolean skipPlaceCheck,
|
||||
public static boolean placeBlock(World world, PlayerEntity player, BlockPos pos, BlockState blockState,
|
||||
ItemStack origstack, Direction facing, Vec3d hitVec, boolean skipPlaceCheck,
|
||||
boolean skipCollisionCheck, boolean playSound) {
|
||||
if (!world.isBlockLoaded(pos, true)) return false;
|
||||
if (!world.isBlockPresent(pos)) return false;
|
||||
ItemStack itemstack = origstack;
|
||||
|
||||
if (blockState.getBlock().isAir(blockState, world, pos) || itemstack.isEmpty()) {
|
||||
dropBlock(world, player, pos);
|
||||
world.removeBlock(pos);
|
||||
world.removeBlock(pos, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -51,9 +47,9 @@ public class SurvivalHelper {
|
||||
if (CompatHelper.isItemBlockProxy(itemstack))
|
||||
itemstack = CompatHelper.getItemBlockByState(itemstack, blockState);
|
||||
|
||||
if (!(itemstack.getItem() instanceof ItemBlock))
|
||||
if (!(itemstack.getItem() instanceof BlockItem))
|
||||
return false;
|
||||
Block block = ((ItemBlock) itemstack.getItem()).getBlock();
|
||||
Block block = ((BlockItem) itemstack.getItem()).getBlock();
|
||||
|
||||
|
||||
//More manual with ItemBlock#placeBlockAt
|
||||
@@ -77,7 +73,7 @@ public class SurvivalHelper {
|
||||
|
||||
// if (result != EnumActionResult.SUCCESS) return false;
|
||||
|
||||
IBlockState afterState = world.getBlockState(pos);
|
||||
BlockState afterState = world.getBlockState(pos);
|
||||
|
||||
if (playSound) {
|
||||
SoundType soundtype = afterState.getBlock().getSoundType(afterState, world, pos, player);
|
||||
@@ -119,8 +115,8 @@ public class SurvivalHelper {
|
||||
|
||||
//Used for all breaking of blocks in this mod.
|
||||
//Checks if area is loaded, if appropriate tool is used in survival mode, and drops the block directly into the players inventory
|
||||
public static boolean breakBlock(World world, EntityPlayer player, BlockPos pos, boolean skipChecks) {
|
||||
if (!world.isBlockLoaded(pos, false)) return false;
|
||||
public static boolean breakBlock(World world, PlayerEntity player, BlockPos pos, boolean skipChecks) {
|
||||
if (!world.isBlockPresent(pos) && !world.isAirBlock(pos)) return false;
|
||||
|
||||
//Check if can break
|
||||
if (skipChecks || canBreak(world, player, pos)) {
|
||||
@@ -133,17 +129,17 @@ public class SurvivalHelper {
|
||||
//Damage tool
|
||||
player.getHeldItemMainhand().onBlockDestroyed(world, world.getBlockState(pos), pos, player);
|
||||
|
||||
world.removeBlock(pos);
|
||||
world.removeBlock(pos, false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//Gives items directly to player
|
||||
public static void dropBlock(World world, EntityPlayer player, BlockPos pos){
|
||||
public static void dropBlock(World world, PlayerEntity player, BlockPos pos){
|
||||
if (player.isCreative()) return;
|
||||
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
BlockState blockState = world.getBlockState(pos);
|
||||
Block block = blockState.getBlock();
|
||||
|
||||
block.harvestBlock(world, player, pos, blockState, world.getTileEntity(pos), player.getHeldItemMainhand());
|
||||
@@ -190,17 +186,17 @@ public class SurvivalHelper {
|
||||
* @param sidePlacedOn
|
||||
* @return Whether the player may place the block at pos with itemstack
|
||||
*/
|
||||
public static boolean canPlace(World world, EntityPlayer player, BlockPos pos, IBlockState newBlockState, ItemStack itemStack, boolean skipCollisionCheck, EnumFacing sidePlacedOn) {
|
||||
public static boolean canPlace(World world, PlayerEntity player, BlockPos pos, BlockState newBlockState, ItemStack itemStack, boolean skipCollisionCheck, Direction sidePlacedOn) {
|
||||
|
||||
//Check if itemstack is correct
|
||||
if (!(itemStack.getItem() instanceof ItemBlock) || Block.getBlockFromItem(itemStack.getItem()) != newBlockState.getBlock()) {
|
||||
if (!(itemStack.getItem() instanceof BlockItem) || Block.getBlockFromItem(itemStack.getItem()) != newBlockState.getBlock()) {
|
||||
// EffortlessBuilding.log(player, "Cannot (re)place block", true);
|
||||
// EffortlessBuilding.log("SurvivalHelper#canPlace: itemstack " + itemStack.toString() + " does not match blockstate " + newBlockState.toString());
|
||||
//Happens when breaking blocks, no need to notify in that case
|
||||
return false;
|
||||
}
|
||||
|
||||
Block block = ((ItemBlock) itemStack.getItem()).getBlock();
|
||||
Block block = ((BlockItem) itemStack.getItem()).getBlock();
|
||||
|
||||
return !itemStack.isEmpty() && canPlayerEdit(player, world, pos, itemStack) &&
|
||||
mayPlace(world, block, newBlockState, pos, skipCollisionCheck, sidePlacedOn, player) &&
|
||||
@@ -208,10 +204,10 @@ public class SurvivalHelper {
|
||||
}
|
||||
|
||||
//Can be harvested with hand? (or in creative)
|
||||
private static boolean canReplace(World world, EntityPlayer player, BlockPos pos){
|
||||
private static boolean canReplace(World world, PlayerEntity player, BlockPos pos){
|
||||
if (player.isCreative()) return true;
|
||||
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
BlockState state = world.getBlockState(pos);
|
||||
|
||||
switch (BuildConfig.survivalBalancers.quickReplaceMiningLevel.get()) {
|
||||
case -1: return state.getMaterial().isToolNotRequired();
|
||||
@@ -225,7 +221,7 @@ public class SurvivalHelper {
|
||||
}
|
||||
|
||||
//From EntityPlayer#canPlayerEdit
|
||||
private static boolean canPlayerEdit(EntityPlayer player, World world, BlockPos pos, ItemStack stack)
|
||||
private static boolean canPlayerEdit(PlayerEntity player, World world, BlockPos pos, ItemStack stack)
|
||||
{
|
||||
if (!world.isBlockModifiable(player, pos)) return false;
|
||||
|
||||
@@ -237,25 +233,25 @@ public class SurvivalHelper {
|
||||
else
|
||||
{
|
||||
//Adventure mode
|
||||
BlockWorldState blockworldstate = new BlockWorldState(world, pos, false);
|
||||
CachedBlockInfo blockworldstate = new CachedBlockInfo(world, pos, false);
|
||||
return stack.canPlaceOn(world.getTags(), blockworldstate);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//From World#mayPlace
|
||||
private static boolean mayPlace(World world, Block blockIn, IBlockState newBlockState, BlockPos pos, boolean skipCollisionCheck, EnumFacing sidePlacedOn, @Nullable Entity placer)
|
||||
private static boolean mayPlace(World world, Block blockIn, BlockState newBlockState, BlockPos pos, boolean skipCollisionCheck, Direction sidePlacedOn, @Nullable Entity placer)
|
||||
{
|
||||
IBlockState iblockstate1 = world.getBlockState(pos);
|
||||
BlockState iblockstate1 = world.getBlockState(pos);
|
||||
VoxelShape voxelShape = skipCollisionCheck ? null : blockIn.getDefaultState().getCollisionShape(world, pos);
|
||||
|
||||
if (voxelShape != null && !world.checkNoEntityCollision(iblockstate1, pos))
|
||||
if (voxelShape != null && !world.checkNoEntityCollision(placer, voxelShape))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//Check if double slab
|
||||
if (placer != null && doesBecomeDoubleSlab(((EntityPlayer) placer), pos, sidePlacedOn)) {
|
||||
if (placer != null && doesBecomeDoubleSlab(((PlayerEntity) placer), pos, sidePlacedOn)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -265,13 +261,14 @@ public class SurvivalHelper {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (iblockstate1.getMaterial() == Material.CIRCUITS && blockIn == Blocks.ANVIL)
|
||||
//TODO 1.14 check what Material.CIRCUITS has become
|
||||
if (iblockstate1.getMaterial() == Material.REDSTONE_LIGHT && blockIn == Blocks.ANVIL)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//Check quickreplace
|
||||
if (placer instanceof EntityPlayer && ModifierSettingsManager.getModifierSettings(((EntityPlayer) placer)).doQuickReplace()) {
|
||||
if (placer instanceof PlayerEntity && ModifierSettingsManager.getModifierSettings(((PlayerEntity) placer)).doQuickReplace()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -282,8 +279,8 @@ public class SurvivalHelper {
|
||||
|
||||
|
||||
//Can break using held tool? (or in creative)
|
||||
public static boolean canBreak(World world, EntityPlayer player, BlockPos pos) {
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
public static boolean canBreak(World world, PlayerEntity player, BlockPos pos) {
|
||||
BlockState blockState = world.getBlockState(pos);
|
||||
if (!world.getFluidState(pos).isEmpty()) return false;
|
||||
|
||||
if (player.isCreative()) return true;
|
||||
@@ -292,9 +289,9 @@ public class SurvivalHelper {
|
||||
}
|
||||
|
||||
//From ForgeHooks#canHarvestBlock
|
||||
public static boolean canHarvestBlock(@Nonnull Block block, @Nonnull EntityPlayer player, @Nonnull World world, @Nonnull BlockPos pos)
|
||||
public static boolean canHarvestBlock(@Nonnull Block block, @Nonnull PlayerEntity player, @Nonnull World world, @Nonnull BlockPos pos)
|
||||
{
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
BlockState state = world.getBlockState(pos);
|
||||
|
||||
//Dont break bedrock
|
||||
if (state.getBlockHardness(world, pos) < 0) {
|
||||
@@ -324,15 +321,15 @@ public class SurvivalHelper {
|
||||
return toolLevel >= block.getHarvestLevel(state);
|
||||
}
|
||||
|
||||
public static boolean doesBecomeDoubleSlab(EntityPlayer player, BlockPos pos, EnumFacing facing) {
|
||||
IBlockState placedBlockState = player.world.getBlockState(pos);
|
||||
public static boolean doesBecomeDoubleSlab(PlayerEntity player, BlockPos pos, Direction facing) {
|
||||
BlockState placedBlockState = player.world.getBlockState(pos);
|
||||
|
||||
ItemStack itemstack = player.getHeldItem(EnumHand.MAIN_HAND);
|
||||
ItemStack itemstack = player.getHeldItem(Hand.MAIN_HAND);
|
||||
if (CompatHelper.isItemBlockProxy(itemstack))
|
||||
itemstack = CompatHelper.getItemBlockFromStack(itemstack);
|
||||
|
||||
if (itemstack.isEmpty() || !(itemstack.getItem() instanceof ItemBlock) || !(((ItemBlock) itemstack.getItem()).getBlock() instanceof BlockSlab)) return false;
|
||||
BlockSlab heldSlab = (BlockSlab) ((ItemBlock) itemstack.getItem()).getBlock();
|
||||
if (itemstack.isEmpty() || !(itemstack.getItem() instanceof BlockItem) || !(((BlockItem) itemstack.getItem()).getBlock() instanceof SlabBlock)) return false;
|
||||
SlabBlock heldSlab = (SlabBlock) ((BlockItem) itemstack.getItem()).getBlock();
|
||||
|
||||
if (placedBlockState.getBlock() == heldSlab) {
|
||||
//TODO 1.13
|
||||
|
||||
@@ -1,21 +1,25 @@
|
||||
package nl.requios.effortlessbuilding.item;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
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;
|
||||
@@ -27,7 +31,6 @@ 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.gui.RandomizerBagGuiHandler;
|
||||
import nl.requios.effortlessbuilding.helper.SurvivalHelper;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -49,39 +52,40 @@ public class ItemRandomizerBag extends Item {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUse(ItemUseContext ctx) {
|
||||
EntityPlayer player = ctx.getPlayer();
|
||||
public ActionResultType onItemUse(ItemUseContext ctx) {
|
||||
PlayerEntity player = ctx.getPlayer();
|
||||
World world = ctx.getWorld();
|
||||
BlockPos pos = ctx.getPos();
|
||||
EnumFacing facing = ctx.getFace();
|
||||
Direction facing = ctx.getFace();
|
||||
ItemStack item = ctx.getItem();
|
||||
Vec3d hitVec = ctx.getHitVec();
|
||||
|
||||
if (player == null) return EnumActionResult.FAIL;
|
||||
if (player == null) return ActionResultType.FAIL;
|
||||
|
||||
if (ctx.isPlacerSneaking()) {
|
||||
if (world.isRemote) return EnumActionResult.SUCCESS;
|
||||
if (world.isRemote) return ActionResultType.SUCCESS;
|
||||
//Open inventory
|
||||
NetworkHooks.openGui((EntityPlayerMP) player, new RandomizerBagGuiHandler());
|
||||
NetworkHooks.openGui((ServerPlayerEntity) player, new ContainerProvider(item));
|
||||
} else {
|
||||
if (world.isRemote) return EnumActionResult.SUCCESS;
|
||||
if (world.isRemote) 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 EnumActionResult.FAIL;
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
|
||||
//Use item
|
||||
//Get bag inventory
|
||||
//TODO offhand support
|
||||
ItemStack bag = player.getHeldItem(EnumHand.MAIN_HAND);
|
||||
ItemStack bag = player.getHeldItem(Hand.MAIN_HAND);
|
||||
IItemHandler bagInventory = getBagInventory(bag);
|
||||
if (bagInventory == null)
|
||||
return EnumActionResult.FAIL;
|
||||
return ActionResultType.FAIL;
|
||||
|
||||
ItemStack toPlace = pickRandomStack(bagInventory);
|
||||
if (toPlace.isEmpty()) return EnumActionResult.FAIL;
|
||||
if (toPlace.isEmpty()) return ActionResultType.FAIL;
|
||||
|
||||
//Previously: use onItemUse to place block (no synergy)
|
||||
//bag.setItemDamage(toPlace.getMetadata());
|
||||
@@ -92,10 +96,10 @@ public class ItemRandomizerBag extends Item {
|
||||
pos = pos.offset(facing);
|
||||
}
|
||||
|
||||
BlockItemUseContext blockItemUseContext = new BlockItemUseContext(world, player, item, pos, facing, ctx.getHitX(), ctx.getHitY(), ctx.getHitZ());
|
||||
IBlockState blockState = Block.getBlockFromItem(toPlace.getItem()).getStateForPlacement(blockItemUseContext);
|
||||
BlockItemUseContext blockItemUseContext = new BlockItemUseContext(new ItemUseContext(player, Hand.MAIN_HAND, new BlockRayTraceResult(hitVec, facing, pos, false)));
|
||||
BlockState blockState = Block.getBlockFromItem(toPlace.getItem()).getStateForPlacement(blockItemUseContext);
|
||||
|
||||
SurvivalHelper.placeBlock(world, player, pos, blockState, toPlace, facing, new Vec3d(ctx.getHitX(), ctx.getHitY(), ctx.getHitZ()), false, false, true);
|
||||
SurvivalHelper.placeBlock(world, player, pos, blockState, toPlace, facing, hitVec, false, false, true);
|
||||
|
||||
//Synergy
|
||||
//Works without calling
|
||||
@@ -104,30 +108,30 @@ public class ItemRandomizerBag extends Item {
|
||||
// Mirror.onBlockPlaced(placeEvent);
|
||||
// Array.onBlockPlaced(placeEvent);
|
||||
}
|
||||
return EnumActionResult.SUCCESS;
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) {
|
||||
ItemStack bag = player.getHeldItem(hand);
|
||||
|
||||
if (player.isSneaking()) {
|
||||
if (world.isRemote) return new ActionResult<>(EnumActionResult.SUCCESS, bag);
|
||||
if (world.isRemote) return new ActionResult<>(ActionResultType.SUCCESS, bag);
|
||||
//Open inventory
|
||||
NetworkHooks.openGui((EntityPlayerMP) player, new RandomizerBagGuiHandler());
|
||||
NetworkHooks.openGui((ServerPlayerEntity) player, new ContainerProvider(bag));
|
||||
} else {
|
||||
//Use item
|
||||
//Get bag inventory
|
||||
IItemHandler bagInventory = getBagInventory(bag);
|
||||
if (bagInventory == null)
|
||||
return new ActionResult<>(EnumActionResult.FAIL, bag);
|
||||
return new ActionResult<>(ActionResultType.FAIL, bag);
|
||||
|
||||
ItemStack toUse = pickRandomStack(bagInventory);
|
||||
if (toUse.isEmpty()) return new ActionResult<>(EnumActionResult.FAIL, bag);
|
||||
if (toUse.isEmpty()) return new ActionResult<>(ActionResultType.FAIL, bag);
|
||||
|
||||
return toUse.useItemRightClick(world, player, hand);
|
||||
}
|
||||
return new ActionResult<>(EnumActionResult.PASS, bag);
|
||||
return new ActionResult<>(ActionResultType.PASS, bag);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -192,14 +196,17 @@ public class ItemRandomizerBag extends Item {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) {
|
||||
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundNBT nbt) {
|
||||
return new ItemHandlerCapabilityProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, @Nullable World world, List<ITextComponent> tooltip, ITooltipFlag flag) {
|
||||
tooltip.add(new TextComponentString(TextFormatting.BLUE + "Rightclick" + TextFormatting.GRAY + " to place a random block"));
|
||||
tooltip.add(new TextComponentString(TextFormatting.BLUE + "Sneak + rightclick" + TextFormatting.GRAY + " to open inventory"));
|
||||
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.getPlayers().size() > 1) {
|
||||
tooltip.add(new StringTextComponent(TextFormatting.YELLOW + "Experimental on servers: may lose inventory"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -215,4 +222,24 @@ public class ItemRandomizerBag extends Item {
|
||||
currentSeed = Calendar.getInstance().getTimeInMillis();
|
||||
rand.setSeed(currentSeed);
|
||||
}
|
||||
|
||||
public static class ContainerProvider implements INamedContainerProvider{
|
||||
|
||||
private 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package nl.requios.effortlessbuilding.item;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import nl.requios.effortlessbuilding.BuildConfig;
|
||||
@@ -26,11 +26,11 @@ public class ItemReachUpgrade1 extends Item {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) {
|
||||
if (player.isCreative()) {
|
||||
if (world.isRemote) EffortlessBuilding.log(player, "Reach upgrades are not necessary in creative.");
|
||||
if (world.isRemote) EffortlessBuilding.log(player, "Still want increased reach? Use the config.");
|
||||
return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(hand));
|
||||
return new ActionResult<>(ActionResultType.PASS, player.getHeldItem(hand));
|
||||
}
|
||||
|
||||
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
|
||||
@@ -50,12 +50,12 @@ public class ItemReachUpgrade1 extends Item {
|
||||
SoundEvent soundEvent = new SoundEvent(new ResourceLocation("item.armor.equip_leather"));
|
||||
player.playSound(soundEvent, 1f, 1f);
|
||||
}
|
||||
return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(hand));
|
||||
return new ActionResult<>(ActionResultType.PASS, player.getHeldItem(hand));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, @Nullable World world, List<ITextComponent> tooltip, ITooltipFlag flag) {
|
||||
tooltip.add(new TextComponentString(TextFormatting.GRAY + "Consume to increase reach to " + TextFormatting.BLUE + BuildConfig.reach.maxReachLevel1.get()));
|
||||
tooltip.add(new StringTextComponent(TextFormatting.GRAY + "Consume to increase reach to " + TextFormatting.BLUE + BuildConfig.reach.maxReachLevel1.get()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package nl.requios.effortlessbuilding.item;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import nl.requios.effortlessbuilding.BuildConfig;
|
||||
@@ -26,11 +26,11 @@ public class ItemReachUpgrade2 extends Item {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) {
|
||||
if (player.isCreative()) {
|
||||
if (world.isRemote) EffortlessBuilding.log(player, "Reach upgrades are not necessary in creative.");
|
||||
if (world.isRemote) EffortlessBuilding.log(player, "Still want increased reach? Use the config.");
|
||||
return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(hand));
|
||||
return new ActionResult<>(ActionResultType.PASS, player.getHeldItem(hand));
|
||||
}
|
||||
|
||||
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
|
||||
@@ -54,13 +54,13 @@ public class ItemReachUpgrade2 extends Item {
|
||||
SoundEvent soundEvent = new SoundEvent(new ResourceLocation("item.armor.equip_leather"));
|
||||
player.playSound(soundEvent, 1f, 1f);
|
||||
}
|
||||
return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(hand));
|
||||
return new ActionResult<>(ActionResultType.PASS, player.getHeldItem(hand));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, @Nullable World world, List<ITextComponent> tooltip, ITooltipFlag flag) {
|
||||
tooltip.add(new TextComponentString(TextFormatting.GRAY + "Consume to increase reach to " + TextFormatting.BLUE + BuildConfig.reach.maxReachLevel2.get()));
|
||||
tooltip.add(new TextComponentString(TextFormatting.GRAY + "Previous upgrades need to be consumed first"));
|
||||
tooltip.add(new StringTextComponent(TextFormatting.GRAY + "Consume to increase reach to " + TextFormatting.BLUE + BuildConfig.reach.maxReachLevel2.get()));
|
||||
tooltip.add(new StringTextComponent(TextFormatting.GRAY + "Previous upgrades need to be consumed first"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package nl.requios.effortlessbuilding.item;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import nl.requios.effortlessbuilding.BuildConfig;
|
||||
@@ -26,11 +26,11 @@ public class ItemReachUpgrade3 extends Item {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) {
|
||||
if (player.isCreative()) {
|
||||
if (world.isRemote) EffortlessBuilding.log(player, "Reach upgrades are not necessary in creative.");
|
||||
if (world.isRemote) EffortlessBuilding.log(player, "Still want increased reach? Use the config.");
|
||||
return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(hand));
|
||||
return new ActionResult<>(ActionResultType.PASS, player.getHeldItem(hand));
|
||||
}
|
||||
|
||||
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
|
||||
@@ -57,13 +57,13 @@ public class ItemReachUpgrade3 extends Item {
|
||||
SoundEvent soundEvent = new SoundEvent(new ResourceLocation("item.armor.equip_leather"));
|
||||
player.playSound(soundEvent, 1f, 1f);
|
||||
}
|
||||
return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(hand));
|
||||
return new ActionResult<>(ActionResultType.PASS, player.getHeldItem(hand));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, @Nullable World world, List<ITextComponent> tooltip, ITooltipFlag flag) {
|
||||
tooltip.add(new TextComponentString(TextFormatting.GRAY + "Consume to increase reach to " + TextFormatting.BLUE + BuildConfig.reach.maxReachLevel3.get()));
|
||||
tooltip.add(new TextComponentString(TextFormatting.GRAY + "Previous upgrades need to be consumed first"));
|
||||
tooltip.add(new StringTextComponent(TextFormatting.GRAY + "Consume to increase reach to " + TextFormatting.BLUE + BuildConfig.reach.maxReachLevel3.get()));
|
||||
tooltip.add(new StringTextComponent(TextFormatting.GRAY + "Previous upgrades need to be consumed first"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package nl.requios.effortlessbuilding.network;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
@@ -20,16 +20,16 @@ import java.util.function.Supplier;
|
||||
*/
|
||||
public class AddUndoMessage {
|
||||
private BlockPos coordinate;
|
||||
private IBlockState previousBlockState;
|
||||
private IBlockState newBlockState;
|
||||
private BlockState previousBlockState;
|
||||
private BlockState newBlockState;
|
||||
|
||||
public AddUndoMessage() {
|
||||
coordinate = BlockPos.ORIGIN;
|
||||
coordinate = BlockPos.ZERO;
|
||||
previousBlockState = null;
|
||||
newBlockState = null;
|
||||
}
|
||||
|
||||
public AddUndoMessage(BlockPos coordinate, IBlockState previousBlockState, IBlockState newBlockState) {
|
||||
public AddUndoMessage(BlockPos coordinate, BlockState previousBlockState, BlockState newBlockState) {
|
||||
this.coordinate = coordinate;
|
||||
this.previousBlockState = previousBlockState;
|
||||
this.newBlockState = newBlockState;
|
||||
@@ -39,11 +39,11 @@ public class AddUndoMessage {
|
||||
return coordinate;
|
||||
}
|
||||
|
||||
public IBlockState getPreviousBlockState() {
|
||||
public BlockState getPreviousBlockState() {
|
||||
return previousBlockState;
|
||||
}
|
||||
|
||||
public IBlockState getNewBlockState() {
|
||||
public BlockState getNewBlockState() {
|
||||
return newBlockState;
|
||||
}
|
||||
|
||||
@@ -57,8 +57,8 @@ public class AddUndoMessage {
|
||||
|
||||
public static AddUndoMessage decode(PacketBuffer buf) {
|
||||
BlockPos coordinate = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt());
|
||||
IBlockState previousBlockState = Block.getStateById(buf.readInt());
|
||||
IBlockState newBlockState = Block.getStateById(buf.readInt());
|
||||
BlockState previousBlockState = Block.getStateById(buf.readInt());
|
||||
BlockState newBlockState = Block.getStateById(buf.readInt());
|
||||
return new AddUndoMessage(coordinate, previousBlockState, newBlockState);
|
||||
}
|
||||
|
||||
@@ -70,12 +70,13 @@ public class AddUndoMessage {
|
||||
if (ctx.get().getDirection().getReceptionSide() == LogicalSide.CLIENT) {
|
||||
//Received clientside
|
||||
|
||||
EntityPlayer player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx);
|
||||
PlayerEntity player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx);
|
||||
//Add to undo stack clientside
|
||||
UndoRedo.addUndo(ctx.get().getSender(), new BlockSet(
|
||||
//Only the appropriate player that needs to add this to the undo stack gets this message
|
||||
UndoRedo.addUndo(player, new BlockSet(
|
||||
new ArrayList<BlockPos>() {{add(message.getCoordinate());}},
|
||||
new ArrayList<IBlockState>() {{add(message.getPreviousBlockState());}},
|
||||
new ArrayList<IBlockState>() {{add(message.getNewBlockState());}},
|
||||
new ArrayList<BlockState>() {{add(message.getPreviousBlockState());}},
|
||||
new ArrayList<BlockState>() {{add(message.getNewBlockState());}},
|
||||
new Vec3d(0,0,0),
|
||||
message.getCoordinate(), message.getCoordinate()));
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package nl.requios.effortlessbuilding.network;
|
||||
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
@@ -19,24 +20,24 @@ public class BlockBrokenMessage {
|
||||
|
||||
private boolean blockHit;
|
||||
private BlockPos blockPos;
|
||||
private EnumFacing sideHit;
|
||||
private Direction sideHit;
|
||||
private Vec3d hitVec;
|
||||
|
||||
public BlockBrokenMessage() {
|
||||
this.blockHit = false;
|
||||
this.blockPos = BlockPos.ORIGIN;
|
||||
this.sideHit = EnumFacing.UP;
|
||||
this.blockPos = BlockPos.ZERO;
|
||||
this.sideHit = Direction.UP;
|
||||
this.hitVec = new Vec3d(0, 0, 0);
|
||||
}
|
||||
|
||||
public BlockBrokenMessage(RayTraceResult result) {
|
||||
this.blockHit = result.type == RayTraceResult.Type.BLOCK;
|
||||
this.blockPos = result.getBlockPos();
|
||||
this.sideHit = result.sideHit;
|
||||
this.hitVec = result.hitVec;
|
||||
public BlockBrokenMessage(BlockRayTraceResult result) {
|
||||
this.blockHit = result.getType() == RayTraceResult.Type.BLOCK;
|
||||
this.blockPos = result.getPos();
|
||||
this.sideHit = result.getFace();
|
||||
this.hitVec = result.getHitVec();
|
||||
}
|
||||
|
||||
public BlockBrokenMessage(boolean blockHit, BlockPos blockPos, EnumFacing sideHit, Vec3d hitVec) {
|
||||
public BlockBrokenMessage(boolean blockHit, BlockPos blockPos, Direction sideHit, Vec3d hitVec) {
|
||||
this.blockHit = blockHit;
|
||||
this.blockPos = blockPos;
|
||||
this.sideHit = sideHit;
|
||||
@@ -51,7 +52,7 @@ public class BlockBrokenMessage {
|
||||
return blockPos;
|
||||
}
|
||||
|
||||
public EnumFacing getSideHit() {
|
||||
public Direction getSideHit() {
|
||||
return sideHit;
|
||||
}
|
||||
|
||||
@@ -73,7 +74,7 @@ public class BlockBrokenMessage {
|
||||
public static BlockBrokenMessage decode(PacketBuffer buf) {
|
||||
boolean blockHit = buf.readBoolean();
|
||||
BlockPos blockPos = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt());
|
||||
EnumFacing sideHit = EnumFacing.byIndex(buf.readInt());
|
||||
Direction sideHit = Direction.byIndex(buf.readInt());
|
||||
Vec3d hitVec = new Vec3d(buf.readDouble(), buf.readDouble(), buf.readDouble());
|
||||
return new BlockBrokenMessage(blockHit, blockPos, sideHit, hitVec);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package nl.requios.effortlessbuilding.network;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
@@ -21,27 +22,27 @@ public class BlockPlacedMessage {
|
||||
|
||||
private boolean blockHit;
|
||||
private BlockPos blockPos;
|
||||
private EnumFacing sideHit;
|
||||
private Direction sideHit;
|
||||
private Vec3d hitVec;
|
||||
private boolean placeStartPos; //prevent double placing in normal mode
|
||||
|
||||
public BlockPlacedMessage() {
|
||||
this.blockHit = false;
|
||||
this.blockPos = BlockPos.ORIGIN;
|
||||
this.sideHit = EnumFacing.UP;
|
||||
this.blockPos = BlockPos.ZERO;
|
||||
this.sideHit = Direction.UP;
|
||||
this.hitVec = new Vec3d(0, 0, 0);
|
||||
this.placeStartPos = true;
|
||||
}
|
||||
|
||||
public BlockPlacedMessage(RayTraceResult result, boolean placeStartPos) {
|
||||
this.blockHit = result.type == RayTraceResult.Type.BLOCK;
|
||||
this.blockPos = result.getBlockPos();
|
||||
this.sideHit = result.sideHit;
|
||||
this.hitVec = result.hitVec;
|
||||
public BlockPlacedMessage(BlockRayTraceResult result, boolean placeStartPos) {
|
||||
this.blockHit = result.getType() == RayTraceResult.Type.BLOCK;
|
||||
this.blockPos = result.getPos();
|
||||
this.sideHit = result.getFace();
|
||||
this.hitVec = result.getHitVec();
|
||||
this.placeStartPos = placeStartPos;
|
||||
}
|
||||
|
||||
public BlockPlacedMessage(boolean blockHit, BlockPos blockPos, EnumFacing sideHit, Vec3d hitVec, boolean placeStartPos) {
|
||||
public BlockPlacedMessage(boolean blockHit, BlockPos blockPos, Direction sideHit, Vec3d hitVec, boolean placeStartPos) {
|
||||
this.blockHit = blockHit;
|
||||
this.blockPos = blockPos;
|
||||
this.sideHit = sideHit;
|
||||
@@ -57,7 +58,7 @@ public class BlockPlacedMessage {
|
||||
return blockPos;
|
||||
}
|
||||
|
||||
public EnumFacing getSideHit() {
|
||||
public Direction getSideHit() {
|
||||
return sideHit;
|
||||
}
|
||||
|
||||
@@ -84,7 +85,7 @@ public class BlockPlacedMessage {
|
||||
public static BlockPlacedMessage decode(PacketBuffer buf) {
|
||||
boolean blockHit = buf.readBoolean();
|
||||
BlockPos blockPos = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt());
|
||||
EnumFacing sideHit = EnumFacing.byIndex(buf.readInt());
|
||||
Direction sideHit = Direction.byIndex(buf.readInt());
|
||||
Vec3d hitVec = new Vec3d(buf.readDouble(), buf.readDouble(), buf.readDouble());
|
||||
boolean placeStartPos = buf.readBoolean();
|
||||
return new BlockPlacedMessage(blockHit, blockPos, sideHit, hitVec, placeStartPos);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package nl.requios.effortlessbuilding.network;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
@@ -25,7 +25,7 @@ public class CancelModeMessage {
|
||||
public static void handle(CancelModeMessage message, Supplier<NetworkEvent.Context> ctx)
|
||||
{
|
||||
ctx.get().enqueueWork(() -> {
|
||||
EntityPlayer player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx);
|
||||
PlayerEntity player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx);
|
||||
|
||||
BuildModes.initializeMode(player);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package nl.requios.effortlessbuilding.network;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
@@ -32,7 +32,7 @@ public class ClearUndoMessage {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
if (ctx.get().getDirection().getReceptionSide() == LogicalSide.CLIENT) {
|
||||
//Received clientside
|
||||
EntityPlayer player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx);
|
||||
PlayerEntity player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx);
|
||||
|
||||
//Add to undo stack clientside
|
||||
UndoRedo.clear(player);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package nl.requios.effortlessbuilding.network;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
@@ -36,7 +36,7 @@ public class ModeActionMessage {
|
||||
public static void handle(ModeActionMessage message, Supplier<NetworkEvent.Context> ctx)
|
||||
{
|
||||
ctx.get().enqueueWork(() -> {
|
||||
EntityPlayer player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx);
|
||||
PlayerEntity player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx);
|
||||
|
||||
ModeOptions.performAction(player, message.action);
|
||||
});
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package nl.requios.effortlessbuilding.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.IThreadListener;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
||||
@@ -41,7 +39,7 @@ public class ModeSettingsMessage {
|
||||
public static void handle(ModeSettingsMessage message, Supplier<NetworkEvent.Context> ctx)
|
||||
{
|
||||
ctx.get().enqueueWork(() -> {
|
||||
EntityPlayer player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx);
|
||||
PlayerEntity player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx);
|
||||
|
||||
// Sanitize
|
||||
ModeSettingsManager.sanitize(message.modeSettings, player);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package nl.requios.effortlessbuilding.network;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
@@ -129,7 +129,7 @@ public class ModifierSettingsMessage {
|
||||
public static void handle(ModifierSettingsMessage message, Supplier<NetworkEvent.Context> ctx)
|
||||
{
|
||||
ctx.get().enqueueWork(() -> {
|
||||
EntityPlayer player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx);
|
||||
PlayerEntity player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx);
|
||||
|
||||
// Sanitize
|
||||
ModifierSettingsManager.sanitize(message.modifierSettings, player);
|
||||
|
||||
@@ -1,19 +1,14 @@
|
||||
package nl.requios.effortlessbuilding.network;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.BlockSet;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.UndoRedo;
|
||||
import nl.requios.effortlessbuilding.proxy.ClientProxy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/***
|
||||
@@ -52,11 +47,15 @@ public class RequestLookAtMessage {
|
||||
if (ctx.get().getDirection().getReceptionSide() == LogicalSide.CLIENT) {
|
||||
//Received clientside
|
||||
//Send back your info
|
||||
EntityPlayer player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx);
|
||||
PlayerEntity player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx);
|
||||
|
||||
//Prevent double placing in normal mode with placeStartPos false
|
||||
//Unless QuickReplace is on, then we do need to place start pos.
|
||||
PacketHandler.INSTANCE.sendToServer(new BlockPlacedMessage(ClientProxy.previousLookAt, message.getPlaceStartPos()));
|
||||
if (ClientProxy.previousLookAt.getType() == RayTraceResult.Type.BLOCK) {
|
||||
PacketHandler.INSTANCE.sendToServer(new BlockPlacedMessage((BlockRayTraceResult) ClientProxy.previousLookAt, message.getPlaceStartPos()));
|
||||
} else {
|
||||
PacketHandler.INSTANCE.sendToServer(new BlockPlacedMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package nl.requios.effortlessbuilding.network;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.BlockSet;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.UndoRedo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class TranslatedLogMessage {
|
||||
private String prefix;
|
||||
private String translationKey;
|
||||
private String suffix;
|
||||
private boolean actionBar;
|
||||
|
||||
public TranslatedLogMessage(){
|
||||
prefix = "";
|
||||
translationKey = "";
|
||||
suffix = "";
|
||||
actionBar = false;
|
||||
}
|
||||
|
||||
public TranslatedLogMessage(String prefix, String translationKey, String suffix, boolean actionBar) {
|
||||
this.prefix = prefix;
|
||||
this.translationKey = translationKey;
|
||||
this.suffix = suffix;
|
||||
this.actionBar = actionBar;
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
public String getTranslationKey() {
|
||||
return translationKey;
|
||||
}
|
||||
|
||||
public String getSuffix() {
|
||||
return suffix;
|
||||
}
|
||||
|
||||
public boolean isActionBar() {
|
||||
return actionBar;
|
||||
}
|
||||
|
||||
public static void encode(TranslatedLogMessage message, PacketBuffer buf) {
|
||||
buf.writeString(message.prefix);
|
||||
buf.writeString(message.translationKey);
|
||||
buf.writeString(message.suffix);
|
||||
buf.writeBoolean(message.actionBar);
|
||||
}
|
||||
|
||||
public static TranslatedLogMessage decode(PacketBuffer buf) {
|
||||
return new TranslatedLogMessage(buf.readString(), buf.readString(), buf.readString(), buf.readBoolean());
|
||||
}
|
||||
|
||||
public static class Handler
|
||||
{
|
||||
public static void handle(TranslatedLogMessage message, Supplier<NetworkEvent.Context> ctx)
|
||||
{
|
||||
ctx.get().enqueueWork(() -> {
|
||||
if (ctx.get().getDirection().getReceptionSide() == LogicalSide.CLIENT) {
|
||||
//Received clientside
|
||||
|
||||
PlayerEntity player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx);
|
||||
EffortlessBuilding.logTranslate(player, message.prefix, message.translationKey, message.suffix, message.actionBar);
|
||||
}
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,39 +1,36 @@
|
||||
package nl.requios.effortlessbuilding.proxy;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.KeyboardListener;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
import net.minecraft.client.gui.ScreenManager;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceFluidMode;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.*;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.GuiOpenEvent;
|
||||
import net.minecraftforge.client.event.InputEvent;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.client.settings.KeyConflictContext;
|
||||
import net.minecraftforge.client.settings.KeyModifier;
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.DeferredWorkQueue;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
@@ -43,11 +40,11 @@ import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
||||
import nl.requios.effortlessbuilding.buildmode.ModeSettingsManager;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
|
||||
import nl.requios.effortlessbuilding.compatibility.CompatHelper;
|
||||
import nl.requios.effortlessbuilding.gui.RandomizerBagScreen;
|
||||
import nl.requios.effortlessbuilding.gui.buildmode.RadialMenu;
|
||||
import nl.requios.effortlessbuilding.gui.buildmodifier.ModifierSettingsGui;
|
||||
import nl.requios.effortlessbuilding.helper.ReachHelper;
|
||||
import nl.requios.effortlessbuilding.network.*;
|
||||
import nl.requios.effortlessbuilding.render.RenderHandler;
|
||||
import nl.requios.effortlessbuilding.render.ShaderHandler;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
@@ -66,9 +63,6 @@ public class ClientProxy implements IProxy {
|
||||
|
||||
public static int ticksInGame = 0;
|
||||
|
||||
private static final HashMap<BuildModes.BuildModeEnum, ResourceLocation> buildModeIcons = new HashMap<>();
|
||||
private static final HashMap<ModeOptions.ActionEnum, ResourceLocation> modeOptionIcons = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void setup(FMLCommonSetupEvent event) {}
|
||||
|
||||
@@ -86,10 +80,10 @@ public class ClientProxy implements IProxy {
|
||||
keyBindings[2] = new KeyBinding("key.effortlessbuilding.creative.desc", KeyConflictContext.IN_GAME, InputMappings.getInputByCode(GLFW.GLFW_KEY_F4, 0), "key.effortlessbuilding.category");
|
||||
keyBindings[3] = new KeyBinding("key.effortlessbuilding.mode.desc", KeyConflictContext.IN_GAME, InputMappings.getInputByCode(GLFW.GLFW_KEY_LEFT_ALT, 0), "key.effortlessbuilding.category") {
|
||||
@Override
|
||||
public boolean func_197983_b(KeyBinding other) {
|
||||
public boolean conflicts(KeyBinding other) {
|
||||
//Does not conflict with Chisels and Bits radial menu
|
||||
if (other.getKey().getKeyCode() == getKey().getKeyCode() && other.getKeyDescription().equals("mod.chiselsandbits.other.mode")) return false;
|
||||
return super.func_197983_b(other);
|
||||
return super.conflicts(other);
|
||||
}
|
||||
};
|
||||
keyBindings[4] = new KeyBinding("key.effortlessbuilding.undo.desc", KeyConflictContext.IN_GAME, KeyModifier.CONTROL, InputMappings.getInputByCode(GLFW.GLFW_KEY_Z, 0), "key.effortlessbuilding.category");
|
||||
@@ -102,47 +96,13 @@ public class ClientProxy implements IProxy {
|
||||
ClientRegistry.registerKeyBinding(keyBindings[i]);
|
||||
}
|
||||
|
||||
DeferredWorkQueue.runLater( () -> ScreenManager.registerFactory(EffortlessBuilding.RANDOMIZER_BAG_CONTAINER, RandomizerBagScreen::new));
|
||||
}
|
||||
|
||||
public EntityPlayer 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());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onEntityJoinWorld(EntityJoinWorldEvent event) {
|
||||
if (event.getEntity() == Minecraft.getInstance().player) {
|
||||
event.getWorld().addEventListener(new RenderHandler());
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onTextureStitch(final TextureStitchEvent.Pre event) {
|
||||
//register icon textures
|
||||
final TextureMap map = event.getMap();
|
||||
|
||||
for ( final BuildModes.BuildModeEnum mode : BuildModes.BuildModeEnum.values() )
|
||||
{
|
||||
final ResourceLocation sprite = new ResourceLocation(EffortlessBuilding.MODID, "icons/" + mode.name().toLowerCase());
|
||||
map.registerSprite(Minecraft.getInstance().getResourceManager(), sprite);
|
||||
buildModeIcons.put(mode, sprite);
|
||||
}
|
||||
|
||||
for ( final ModeOptions.ActionEnum action : ModeOptions.ActionEnum.values() )
|
||||
{
|
||||
final ResourceLocation sprite = new ResourceLocation(EffortlessBuilding.MODID, "icons/" + action.name().toLowerCase());
|
||||
map.registerSprite(Minecraft.getInstance().getResourceManager(), sprite);
|
||||
modeOptionIcons.put(action, sprite);
|
||||
}
|
||||
}
|
||||
|
||||
public static TextureAtlasSprite getBuildModeIcon(BuildModes.BuildModeEnum mode) {
|
||||
return Minecraft.getInstance().getTextureMap().getSprite(buildModeIcons.get(mode));
|
||||
}
|
||||
|
||||
public static TextureAtlasSprite getModeOptionIcon(ModeOptions.ActionEnum action) {
|
||||
return Minecraft.getInstance().getTextureMap().getSprite(modeOptionIcons.get(action));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onClientTick(TickEvent.ClientTickEvent event) {
|
||||
|
||||
@@ -160,12 +120,12 @@ public class ClientProxy implements IProxy {
|
||||
return;
|
||||
}
|
||||
|
||||
if (objectMouseOver.type == RayTraceResult.Type.BLOCK) {
|
||||
if (currentLookAt.type != RayTraceResult.Type.BLOCK) {
|
||||
if (objectMouseOver.getType() == RayTraceResult.Type.BLOCK) {
|
||||
if (currentLookAt.getType() != RayTraceResult.Type.BLOCK) {
|
||||
currentLookAt = objectMouseOver;
|
||||
previousLookAt = objectMouseOver;
|
||||
} else {
|
||||
if (currentLookAt.getBlockPos() != objectMouseOver.getBlockPos()) {
|
||||
if (((BlockRayTraceResult) currentLookAt).getPos() != ((BlockRayTraceResult) objectMouseOver).getPos()) {
|
||||
previousLookAt = currentLookAt;
|
||||
currentLookAt = objectMouseOver;
|
||||
}
|
||||
@@ -173,8 +133,8 @@ public class ClientProxy implements IProxy {
|
||||
}
|
||||
|
||||
} else if (event.phase == TickEvent.Phase.END){
|
||||
GuiScreen gui = Minecraft.getInstance().currentScreen;
|
||||
if(gui == null || !gui.doesGuiPauseGame()) {
|
||||
Screen gui = Minecraft.getInstance().currentScreen;
|
||||
if(gui == null || !gui.isPauseScreen()) {
|
||||
ticksInGame++;
|
||||
}
|
||||
|
||||
@@ -189,7 +149,7 @@ public class ClientProxy implements IProxy {
|
||||
|
||||
private static void onMouseInput() {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
EntityPlayerSP player = mc.player;
|
||||
ClientPlayerEntity player = mc.player;
|
||||
if (player == null) return;
|
||||
BuildModes.BuildModeEnum buildMode = ModeSettingsManager.getModeSettings(player).getBuildMode();
|
||||
|
||||
@@ -206,28 +166,34 @@ public class ClientProxy implements IProxy {
|
||||
if (placeCooldown <= 0) {
|
||||
placeCooldown = 4;
|
||||
|
||||
ItemStack currentItemStack = player.getHeldItem(EnumHand.MAIN_HAND);
|
||||
if (currentItemStack.getItem() instanceof ItemBlock ||
|
||||
ItemStack currentItemStack = player.getHeldItem(Hand.MAIN_HAND);
|
||||
if (currentItemStack.getItem() instanceof BlockItem ||
|
||||
(CompatHelper.isItemBlockProxy(currentItemStack) && !player.isSneaking())) {
|
||||
|
||||
ItemStack itemStack = CompatHelper.getItemBlockFromStack(currentItemStack);
|
||||
|
||||
//find position in distance
|
||||
RayTraceResult lookingAt = getLookingAt(player);
|
||||
BuildModes.onBlockPlacedMessage(player, lookingAt == null ? new BlockPlacedMessage() : new BlockPlacedMessage(lookingAt, true));
|
||||
PacketHandler.INSTANCE.sendToServer(lookingAt == null ? new BlockPlacedMessage() : new BlockPlacedMessage(lookingAt, true));
|
||||
if (lookingAt != null && lookingAt.getType() == RayTraceResult.Type.BLOCK) {
|
||||
BlockRayTraceResult blockLookingAt = (BlockRayTraceResult) lookingAt;
|
||||
|
||||
//play sound if further than normal
|
||||
if (lookingAt != null && lookingAt.type == RayTraceResult.Type.BLOCK &&
|
||||
(lookingAt.hitVec.subtract(player.getEyePosition(1f))).lengthSquared() > 25f &&
|
||||
itemStack.getItem() instanceof ItemBlock) {
|
||||
BuildModes.onBlockPlacedMessage(player, new BlockPlacedMessage(blockLookingAt, true));
|
||||
PacketHandler.INSTANCE.sendToServer(new BlockPlacedMessage(blockLookingAt, true));
|
||||
|
||||
IBlockState state = ((ItemBlock) itemStack.getItem()).getBlock().getDefaultState();
|
||||
BlockPos blockPos = lookingAt.getBlockPos();
|
||||
SoundType soundType = state.getBlock().getSoundType(state, player.world, blockPos, player);
|
||||
player.world.playSound(player, player.getPosition(), soundType.getPlaceSound(), SoundCategory.BLOCKS,
|
||||
0.4f, soundType.getPitch() * 1f);
|
||||
player.swingArm(EnumHand.MAIN_HAND);
|
||||
//play sound if further than normal
|
||||
if ((blockLookingAt.getHitVec().subtract(player.getEyePosition(1f))).lengthSquared() > 25f &&
|
||||
itemStack.getItem() instanceof BlockItem) {
|
||||
|
||||
BlockState state = ((BlockItem) itemStack.getItem()).getBlock().getDefaultState();
|
||||
BlockPos blockPos = blockLookingAt.getPos();
|
||||
SoundType soundType = state.getBlock().getSoundType(state, player.world, blockPos, player);
|
||||
player.world.playSound(player, player.getPosition(), soundType.getPlaceSound(), SoundCategory.BLOCKS,
|
||||
0.4f, soundType.getPitch() * 1f);
|
||||
player.swingArm(Hand.MAIN_HAND);
|
||||
}
|
||||
} else {
|
||||
BuildModes.onBlockPlacedMessage(player, new BlockPlacedMessage());
|
||||
PacketHandler.INSTANCE.sendToServer(new BlockPlacedMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -252,19 +218,25 @@ public class ClientProxy implements IProxy {
|
||||
if (!ReachHelper.canBreakFar(player)) return;
|
||||
|
||||
RayTraceResult lookingAt = getLookingAt(player);
|
||||
BuildModes.onBlockBrokenMessage(player, lookingAt == null ? new BlockBrokenMessage() : new BlockBrokenMessage(lookingAt));
|
||||
PacketHandler.INSTANCE.sendToServer(lookingAt == null ? new BlockBrokenMessage() : new BlockBrokenMessage(lookingAt));
|
||||
if (lookingAt != null && lookingAt.getType() == RayTraceResult.Type.BLOCK) {
|
||||
BlockRayTraceResult blockLookingAt = (BlockRayTraceResult) lookingAt;
|
||||
|
||||
//play sound if further than normal
|
||||
if (lookingAt != null && lookingAt.type == RayTraceResult.Type.BLOCK &&
|
||||
(lookingAt.hitVec.subtract(player.getEyePosition(1f))).lengthSquared() > 25f) {
|
||||
BuildModes.onBlockBrokenMessage(player, new BlockBrokenMessage(blockLookingAt));
|
||||
PacketHandler.INSTANCE.sendToServer(new BlockBrokenMessage(blockLookingAt));
|
||||
|
||||
BlockPos blockPos = lookingAt.getBlockPos();
|
||||
IBlockState state = player.world.getBlockState(blockPos);
|
||||
SoundType soundtype = state.getBlock().getSoundType(state, player.world, blockPos, player);
|
||||
player.world.playSound(player, player.getPosition(), soundtype.getBreakSound(), SoundCategory.BLOCKS,
|
||||
0.4f, soundtype.getPitch() * 1f);
|
||||
player.swingArm(EnumHand.MAIN_HAND);
|
||||
//play sound if further than normal
|
||||
if ((blockLookingAt.getHitVec().subtract(player.getEyePosition(1f))).lengthSquared() > 25f) {
|
||||
|
||||
BlockPos blockPos = blockLookingAt.getPos();
|
||||
BlockState state = player.world.getBlockState(blockPos);
|
||||
SoundType soundtype = state.getBlock().getSoundType(state, player.world, blockPos, player);
|
||||
player.world.playSound(player, player.getPosition(), soundtype.getBreakSound(), SoundCategory.BLOCKS,
|
||||
0.4f, soundtype.getPitch() * 1f);
|
||||
player.swingArm(Hand.MAIN_HAND);
|
||||
}
|
||||
} else {
|
||||
BuildModes.onBlockBrokenMessage(player, new BlockBrokenMessage());
|
||||
PacketHandler.INSTANCE.sendToServer(new BlockBrokenMessage());
|
||||
}
|
||||
}
|
||||
else if (buildMode == BuildModes.BuildModeEnum.NORMAL_PLUS) {
|
||||
@@ -281,7 +253,7 @@ public class ClientProxy implements IProxy {
|
||||
|
||||
@SubscribeEvent(receiveCanceled = true)
|
||||
public static void onKeyPress(InputEvent.KeyInputEvent event) {
|
||||
EntityPlayerSP player = Minecraft.getInstance().player;
|
||||
ClientPlayerEntity player = Minecraft.getInstance().player;
|
||||
|
||||
//Remember to send packet to server if necessary
|
||||
//Show Modifier Settings GUI
|
||||
@@ -349,7 +321,7 @@ public class ClientProxy implements IProxy {
|
||||
|
||||
public static void openModifierSettings() {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
EntityPlayerSP player = mc.player;
|
||||
ClientPlayerEntity player = mc.player;
|
||||
|
||||
RadialMenu.instance.setVisibility(0f);
|
||||
|
||||
@@ -367,27 +339,29 @@ public class ClientProxy implements IProxy {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onGuiOpen(GuiOpenEvent event) {
|
||||
EntityPlayer player = Minecraft.getInstance().player;
|
||||
PlayerEntity player = Minecraft.getInstance().player;
|
||||
if (player != null) {
|
||||
BuildModes.initializeMode(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static RayTraceResult getLookingAt(EntityPlayer player) {
|
||||
// World world = player.world;
|
||||
public static RayTraceResult getLookingAt(PlayerEntity player) {
|
||||
World world = player.world;
|
||||
|
||||
//base distance off of player ability (config)
|
||||
float raytraceRange = ReachHelper.getPlacementReach(player);
|
||||
|
||||
// Vec3d look = player.getLookVec();
|
||||
// Vec3d start = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ);
|
||||
// Vec3d end = new Vec3d(player.posX + look.x * raytraceRange, player.posY + player.getEyeHeight() + look.y * raytraceRange, player.posZ + look.z * raytraceRange);
|
||||
return player.rayTrace(raytraceRange, 1f, RayTraceFluidMode.NEVER);
|
||||
// return world.rayTraceBlocks(start, end, false, false, false);
|
||||
Vec3d look = player.getLookVec();
|
||||
Vec3d start = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ);
|
||||
Vec3d end = new Vec3d(player.posX + look.x * raytraceRange, player.posY + player.getEyeHeight() + look.y * raytraceRange, player.posZ + look.z * raytraceRange);
|
||||
// return player.rayTrace(raytraceRange, 1f, RayTraceFluidMode.NEVER);
|
||||
//TODO 1.14 check if correct
|
||||
return world.rayTraceBlocks(new RayTraceContext(start, end, RayTraceContext.BlockMode.COLLIDER, RayTraceContext.FluidMode.NONE, player));
|
||||
}
|
||||
|
||||
public static void logTranslate(String key) {
|
||||
EffortlessBuilding.log(Minecraft.getInstance().player, I18n.format(key), true);
|
||||
@Override
|
||||
public void logTranslate(PlayerEntity player, String prefix, String translationKey, String suffix, boolean actionBar) {
|
||||
EffortlessBuilding.log(Minecraft.getInstance().player, prefix + I18n.format(translationKey) + suffix, actionBar);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package nl.requios.effortlessbuilding.proxy;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
@@ -12,5 +12,7 @@ public interface IProxy {
|
||||
|
||||
void clientSetup(final FMLClientSetupEvent event);
|
||||
|
||||
EntityPlayer getPlayerEntityFromContext(Supplier<NetworkEvent.Context> ctx);
|
||||
PlayerEntity getPlayerEntityFromContext(Supplier<NetworkEvent.Context> ctx);
|
||||
|
||||
void logTranslate(PlayerEntity player, String prefix, String translationKey, String suffix, boolean actionBar);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
package nl.requios.effortlessbuilding.proxy;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
import net.minecraftforge.fml.network.PacketDistributor;
|
||||
import nl.requios.effortlessbuilding.network.PacketHandler;
|
||||
import nl.requios.effortlessbuilding.network.TranslatedLogMessage;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@@ -17,7 +21,12 @@ public class ServerProxy implements IProxy {
|
||||
@Override
|
||||
public void clientSetup(FMLClientSetupEvent event) {}
|
||||
|
||||
public EntityPlayer getPlayerEntityFromContext(Supplier<NetworkEvent.Context> ctx){
|
||||
public PlayerEntity getPlayerEntityFromContext(Supplier<NetworkEvent.Context> ctx){
|
||||
return ctx.get().getSender();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logTranslate(PlayerEntity player, String prefix, String translationKey, String suffix, boolean actionBar) {
|
||||
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), new TranslatedLogMessage(prefix, translationKey, suffix, actionBar));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,17 @@
|
||||
package nl.requios.effortlessbuilding.render;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
import net.minecraft.client.renderer.BlockRendererDispatcher;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.*;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@@ -33,9 +29,7 @@ import nl.requios.effortlessbuilding.helper.ReachHelper;
|
||||
import nl.requios.effortlessbuilding.helper.SurvivalHelper;
|
||||
import nl.requios.effortlessbuilding.item.ItemRandomizerBag;
|
||||
import nl.requios.effortlessbuilding.proxy.ClientProxy;
|
||||
import org.lwjgl.opengl.ARBMultitexture;
|
||||
import org.lwjgl.opengl.ARBShaderObjects;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -45,7 +39,7 @@ import java.util.function.Consumer;
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class BlockPreviewRenderer {
|
||||
private static List<BlockPos> previousCoordinates;
|
||||
private static List<IBlockState> previousBlockStates;
|
||||
private static List<BlockState> previousBlockStates;
|
||||
private static List<ItemStack> previousItemStacks;
|
||||
private static BlockPos previousFirstPos;
|
||||
private static BlockPos previousSecondPos;
|
||||
@@ -54,13 +48,13 @@ public class BlockPreviewRenderer {
|
||||
static class PlacedData {
|
||||
float time;
|
||||
List<BlockPos> coordinates;
|
||||
List<IBlockState> blockStates;
|
||||
List<BlockState> blockStates;
|
||||
List<ItemStack> itemStacks;
|
||||
BlockPos firstPos;
|
||||
BlockPos secondPos;
|
||||
boolean breaking;
|
||||
|
||||
public PlacedData(float time, List<BlockPos> coordinates, List<IBlockState> blockStates,
|
||||
public PlacedData(float time, List<BlockPos> coordinates, List<BlockState> blockStates,
|
||||
List<ItemStack> itemStacks, BlockPos firstPos, BlockPos secondPos, boolean breaking) {
|
||||
this.time = time;
|
||||
this.coordinates = coordinates;
|
||||
@@ -77,7 +71,7 @@ public class BlockPreviewRenderer {
|
||||
private static final int primaryTextureUnit = 0;
|
||||
private static final int secondaryTextureUnit = 2;
|
||||
|
||||
public static void render(EntityPlayer player, ModifierSettings modifierSettings, ModeSettings modeSettings) {
|
||||
public static void render(PlayerEntity player, ModifierSettings modifierSettings, ModeSettings modeSettings) {
|
||||
|
||||
//Render placed blocks with dissolve effect
|
||||
//Use fancy shader if config allows, otherwise no dissolve
|
||||
@@ -108,19 +102,20 @@ public class BlockPreviewRenderer {
|
||||
boolean toolInHand = !(!mainhand.isEmpty() && CompatHelper.isItemBlockProxy(mainhand));
|
||||
|
||||
BlockPos startPos = null;
|
||||
EnumFacing sideHit = null;
|
||||
Direction sideHit = null;
|
||||
Vec3d hitVec = null;
|
||||
|
||||
//Checking for null is necessary! Even in vanilla when looking down ladders it is occasionally null (instead of Type MISS)
|
||||
if (lookingAt != null && lookingAt.type == RayTraceResult.Type.BLOCK) {
|
||||
startPos = lookingAt.getBlockPos();
|
||||
if (lookingAt != null && lookingAt.getType() == RayTraceResult.Type.BLOCK) {
|
||||
BlockRayTraceResult blockLookingAt = (BlockRayTraceResult) lookingAt;
|
||||
startPos = blockLookingAt.getPos();
|
||||
|
||||
//Check if tool (or none) in hand
|
||||
//TODO 1.13 replaceable
|
||||
boolean replaceable = player.world.getBlockState(startPos).getBlock().getMaterial(player.world.getBlockState(startPos)).isReplaceable();
|
||||
boolean becomesDoubleSlab = SurvivalHelper.doesBecomeDoubleSlab(player, startPos, lookingAt.sideHit);
|
||||
boolean becomesDoubleSlab = SurvivalHelper.doesBecomeDoubleSlab(player, startPos, blockLookingAt.getFace());
|
||||
if (!modifierSettings.doQuickReplace() && !toolInHand && !replaceable && !becomesDoubleSlab) {
|
||||
startPos = startPos.offset(lookingAt.sideHit);
|
||||
startPos = startPos.offset(blockLookingAt.getFace());
|
||||
}
|
||||
|
||||
//Get under tall grass and other replaceable blocks
|
||||
@@ -128,8 +123,8 @@ public class BlockPreviewRenderer {
|
||||
startPos = startPos.down();
|
||||
}
|
||||
|
||||
sideHit = lookingAt.sideHit;
|
||||
hitVec = lookingAt.hitVec;
|
||||
sideHit = blockLookingAt.getFace();
|
||||
hitVec = blockLookingAt.getHitVec();
|
||||
}
|
||||
|
||||
//Dont render if in normal mode and modifiers are disabled
|
||||
@@ -153,7 +148,7 @@ public class BlockPreviewRenderer {
|
||||
List<BlockPos> startCoordinates = BuildModes.findCoordinates(player, startPos, breaking || modifierSettings.doQuickReplace());
|
||||
|
||||
//Remember first and last point for the shader
|
||||
BlockPos firstPos = BlockPos.ORIGIN, secondPos = BlockPos.ORIGIN;
|
||||
BlockPos firstPos = BlockPos.ZERO, secondPos = BlockPos.ZERO;
|
||||
if (!startCoordinates.isEmpty()) {
|
||||
firstPos = startCoordinates.get(0);
|
||||
secondPos = startCoordinates.get(startCoordinates.size() - 1);
|
||||
@@ -174,7 +169,7 @@ public class BlockPreviewRenderer {
|
||||
|
||||
//Get blockstates
|
||||
List<ItemStack> itemStacks = new ArrayList<>();
|
||||
List<IBlockState> blockStates = new ArrayList<>();
|
||||
List<BlockState> blockStates = new ArrayList<>();
|
||||
if (breaking) {
|
||||
//Find blockstate of world
|
||||
for (BlockPos coordinate : newCoordinates) {
|
||||
@@ -275,15 +270,16 @@ public class BlockPreviewRenderer {
|
||||
//Find proper raytrace: either normal range or increased range depending on canBreakFar
|
||||
RayTraceResult objectMouseOver = Minecraft.getInstance().objectMouseOver;
|
||||
RayTraceResult breakingRaytrace = ReachHelper.canBreakFar(player) ? lookingAt : objectMouseOver;
|
||||
if (toolInHand && breakingRaytrace != null && breakingRaytrace.type == RayTraceResult.Type.BLOCK) {
|
||||
List<BlockPos> breakCoordinates = BuildModifiers.findCoordinates(player, breakingRaytrace.getBlockPos());
|
||||
if (toolInHand && breakingRaytrace != null && breakingRaytrace.getType() == RayTraceResult.Type.BLOCK) {
|
||||
BlockRayTraceResult blockBreakingRaytrace = (BlockRayTraceResult) breakingRaytrace;
|
||||
List<BlockPos> breakCoordinates = BuildModifiers.findCoordinates(player, blockBreakingRaytrace.getPos());
|
||||
|
||||
//Only render first outline if further than normal reach
|
||||
boolean excludeFirst = objectMouseOver != null && objectMouseOver.type == RayTraceResult.Type.BLOCK;
|
||||
boolean excludeFirst = objectMouseOver != null && objectMouseOver.getType() == RayTraceResult.Type.BLOCK;
|
||||
for (int i = excludeFirst ? 1 : 0; i < breakCoordinates.size(); i++) {
|
||||
BlockPos coordinate = breakCoordinates.get(i);
|
||||
|
||||
IBlockState blockState = player.world.getBlockState(coordinate);
|
||||
BlockState blockState = player.world.getBlockState(coordinate);
|
||||
if (!blockState.getBlock().isAir(blockState, player.world, coordinate)) {
|
||||
if (SurvivalHelper.canBreak(player.world, player, coordinate) || i == 0) {
|
||||
VoxelShape collisionShape = blockState.getCollisionShape(player.world, coordinate);
|
||||
@@ -303,10 +299,10 @@ public class BlockPreviewRenderer {
|
||||
BuildConfig.visuals.alwaysShowBlockPreview.get();
|
||||
}
|
||||
|
||||
protected static int renderBlockPreviews(List<BlockPos> coordinates, List<IBlockState> blockStates,
|
||||
protected static int renderBlockPreviews(List<BlockPos> coordinates, List<BlockState> blockStates,
|
||||
List<ItemStack> itemStacks, float dissolve, BlockPos firstPos,
|
||||
BlockPos secondPos, boolean checkCanPlace, boolean red) {
|
||||
EntityPlayer player = Minecraft.getInstance().player;
|
||||
PlayerEntity player = Minecraft.getInstance().player;
|
||||
ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
|
||||
BlockRendererDispatcher dispatcher = Minecraft.getInstance().getBlockRendererDispatcher();
|
||||
int blocksValid = 0;
|
||||
@@ -315,7 +311,7 @@ public class BlockPreviewRenderer {
|
||||
|
||||
for (int i = coordinates.size() - 1; i >= 0; i--) {
|
||||
BlockPos blockPos = coordinates.get(i);
|
||||
IBlockState blockState = blockStates.get(i);
|
||||
BlockState blockState = blockStates.get(i);
|
||||
ItemStack itemstack = itemStacks.isEmpty() ? ItemStack.EMPTY : itemStacks.get(i);
|
||||
if (CompatHelper.isItemBlockProxy(itemstack))
|
||||
itemstack = CompatHelper.getItemBlockByState(itemstack, blockState);
|
||||
@@ -323,7 +319,7 @@ public class BlockPreviewRenderer {
|
||||
//Check if can place
|
||||
//If check is turned off, check if blockstate is the same (for dissolve effect)
|
||||
if ((!checkCanPlace /*&& player.world.getNewBlockState(blockPos) == blockState*/) || //TODO enable (breaks breaking shader)
|
||||
SurvivalHelper.canPlace(player.world, player, blockPos, blockState, itemstack, modifierSettings.doQuickReplace(), EnumFacing.UP)) {
|
||||
SurvivalHelper.canPlace(player.world, player, blockPos, blockState, itemstack, modifierSettings.doQuickReplace(), Direction.UP)) {
|
||||
|
||||
ShaderHandler.useShader(ShaderHandler.dissolve, generateShaderCallback(dissolve,
|
||||
new Vec3d(blockPos), new Vec3d(firstPos), new Vec3d(secondPos),
|
||||
@@ -339,9 +335,9 @@ public class BlockPreviewRenderer {
|
||||
onBlocksPlaced(previousCoordinates, previousItemStacks, previousBlockStates, previousFirstPos, previousSecondPos);
|
||||
}
|
||||
|
||||
public static void onBlocksPlaced(List<BlockPos> coordinates, List<ItemStack> itemStacks, List<IBlockState> blockStates,
|
||||
public static void onBlocksPlaced(List<BlockPos> coordinates, List<ItemStack> itemStacks, List<BlockState> blockStates,
|
||||
BlockPos firstPos, BlockPos secondPos) {
|
||||
EntityPlayerSP player = Minecraft.getInstance().player;
|
||||
ClientPlayerEntity player = Minecraft.getInstance().player;
|
||||
ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
|
||||
ModeSettings modeSettings = ModeSettingsManager.getModeSettings(player);
|
||||
|
||||
@@ -363,9 +359,9 @@ public class BlockPreviewRenderer {
|
||||
onBlocksBroken(previousCoordinates, previousItemStacks, previousBlockStates, previousFirstPos, previousSecondPos);
|
||||
}
|
||||
|
||||
public static void onBlocksBroken(List<BlockPos> coordinates, List<ItemStack> itemStacks, List<IBlockState> blockStates,
|
||||
public static void onBlocksBroken(List<BlockPos> coordinates, List<ItemStack> itemStacks, List<BlockState> blockStates,
|
||||
BlockPos firstPos, BlockPos secondPos) {
|
||||
EntityPlayerSP player = Minecraft.getInstance().player;
|
||||
ClientPlayerEntity player = Minecraft.getInstance().player;
|
||||
ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
|
||||
ModeSettings modeSettings = ModeSettingsManager.getModeSettings(player);
|
||||
|
||||
@@ -399,18 +395,18 @@ public class BlockPreviewRenderer {
|
||||
int imageUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "image");
|
||||
int maskUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "mask");
|
||||
|
||||
GlStateManager.enableTexture2D();
|
||||
GlStateManager.enableTexture();
|
||||
GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
|
||||
|
||||
//mask
|
||||
ARBShaderObjects.glUniform1iARB(maskUniform, secondaryTextureUnit);
|
||||
OpenGlHelper.glActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + secondaryTextureUnit);
|
||||
glActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + secondaryTextureUnit);
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, mc.getTextureManager().getTexture(ShaderHandler.shaderMaskTextureLocation).getGlTextureId());
|
||||
|
||||
//image
|
||||
ARBShaderObjects.glUniform1iARB(imageUniform, primaryTextureUnit);
|
||||
OpenGlHelper.glActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + primaryTextureUnit);
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, mc.getTextureManager().getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).getGlTextureId());
|
||||
glActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + primaryTextureUnit);
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, mc.getTextureManager().getTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE).getGlTextureId());
|
||||
|
||||
//blockpos
|
||||
ARBShaderObjects.glUniform3fARB(blockposUniform, (float) blockpos.x, (float) blockpos.y, (float) blockpos.z);
|
||||
@@ -426,7 +422,16 @@ public class BlockPreviewRenderer {
|
||||
};
|
||||
}
|
||||
|
||||
private static void sortOnDistanceToPlayer(List<BlockPos> coordinates, EntityPlayer player) {
|
||||
public static void glActiveTexture(int texture) {
|
||||
if (GL.getCapabilities().GL_ARB_multitexture && !GL.getCapabilities().OpenGL13) {
|
||||
ARBMultitexture.glActiveTextureARB(texture);
|
||||
} else {
|
||||
GL13.glActiveTexture(texture);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void sortOnDistanceToPlayer(List<BlockPos> coordinates, PlayerEntity player) {
|
||||
|
||||
Collections.sort(coordinates, (lhs, rhs) -> {
|
||||
// -1 - less than, 1 - greater than, 0 - equal
|
||||
|
||||
@@ -1,26 +1,22 @@
|
||||
package nl.requios.effortlessbuilding.render;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.SimpleSound;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
import net.minecraft.client.renderer.BlockRendererDispatcher;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.particles.IParticleData;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.SoundEvents;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.IWorldEventListener;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||
@@ -29,11 +25,9 @@ import net.minecraftforge.fml.common.Mod;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
||||
import nl.requios.effortlessbuilding.buildmode.ModeSettingsManager;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.BuildModifiers;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
|
||||
import nl.requios.effortlessbuilding.gui.buildmode.RadialMenu;
|
||||
import nl.requios.effortlessbuilding.helper.ReachHelper;
|
||||
import nl.requios.effortlessbuilding.helper.SurvivalHelper;
|
||||
import nl.requios.effortlessbuilding.network.ModeActionMessage;
|
||||
import nl.requios.effortlessbuilding.network.ModeSettingsMessage;
|
||||
import nl.requios.effortlessbuilding.network.PacketHandler;
|
||||
@@ -41,18 +35,15 @@ import nl.requios.effortlessbuilding.proxy.ClientProxy;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL14;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
/***
|
||||
* Main render class for Effortless Building
|
||||
*/
|
||||
@Mod.EventBusSubscriber(value = Dist.CLIENT)
|
||||
public class RenderHandler implements IWorldEventListener {
|
||||
public class RenderHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onRender(RenderWorldLastEvent event) {
|
||||
EntityPlayer player = Minecraft.getInstance().player;
|
||||
PlayerEntity player = Minecraft.getInstance().player;
|
||||
ModeSettingsManager.ModeSettings modeSettings = ModeSettingsManager.getModeSettings(player);
|
||||
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
|
||||
|
||||
@@ -71,7 +62,7 @@ public class RenderHandler implements IWorldEventListener {
|
||||
//Display Radial Menu
|
||||
public static void onRenderGameOverlay(final RenderGameOverlayEvent.Post event) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
EntityPlayerSP player = mc.player;
|
||||
ClientPlayerEntity player = mc.player;
|
||||
|
||||
//check if chisel and bits tool in hand (and has menu)
|
||||
// final boolean hasChiselInHand = CompatHelper.chiselsAndBitsProxy.isHoldingChiselTool(EnumHand.MAIN_HAND);
|
||||
@@ -150,14 +141,15 @@ public class RenderHandler implements IWorldEventListener {
|
||||
}
|
||||
|
||||
private static void begin(float partialTicks) {
|
||||
EntityPlayer player = Minecraft.getInstance().player;
|
||||
double playerX = player.prevPosX + (player.posX - player.prevPosX) * partialTicks;
|
||||
double playerY = player.prevPosY + (player.posY - player.prevPosY) * partialTicks;
|
||||
double playerZ = player.prevPosZ + (player.posZ - player.prevPosZ) * partialTicks;
|
||||
Vec3d playerPos = new Vec3d(playerX, playerY, playerZ);
|
||||
// PlayerEntity player = Minecraft.getInstance().player;
|
||||
// double playerX = player.prevPosX + (player.posX - player.prevPosX) * partialTicks;
|
||||
// double playerY = player.prevPosY + (player.posY - player.prevPosY) * partialTicks;
|
||||
// double playerZ = player.prevPosZ + (player.posZ - player.prevPosZ) * partialTicks;
|
||||
// Vec3d playerPos = new Vec3d(playerX, playerY, playerZ);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(-playerPos.x, -playerPos.y, -playerPos.z);
|
||||
// GL11.glTranslated(-playerPos.x, -playerPos.y, -playerPos.z);
|
||||
GlStateManager.translated(-TileEntityRendererDispatcher.staticPlayerX, -TileEntityRendererDispatcher.staticPlayerY, -TileEntityRendererDispatcher.staticPlayerZ);
|
||||
|
||||
GL11.glDepthMask(false);
|
||||
}
|
||||
@@ -202,7 +194,7 @@ public class RenderHandler implements IWorldEventListener {
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
protected static void renderBlockPreview(BlockRendererDispatcher dispatcher, BlockPos blockPos, IBlockState blockState) {
|
||||
protected static void renderBlockPreview(BlockRendererDispatcher dispatcher, BlockPos blockPos, BlockState blockState) {
|
||||
if (blockState == null) return;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
@@ -252,80 +244,24 @@ public class RenderHandler implements IWorldEventListener {
|
||||
WorldRenderer.drawShape(collisionShape, pos.getX(), pos.getY(), pos.getZ(), (float) color.x, (float) color.y, (float) color.z, 0.4f);
|
||||
}
|
||||
|
||||
//IWORLDEVENTLISTENER IMPLEMENTATION
|
||||
@Override
|
||||
public void notifyBlockUpdate(IBlockReader worldIn, BlockPos pos, IBlockState oldState, IBlockState newState, int flags) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyLightSet(BlockPos pos) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markBlockRangeForRenderUpdate(int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSoundToAllNearExcept(@Nullable EntityPlayer player, SoundEvent soundIn, SoundCategory category,
|
||||
double x, double y, double z, float volume, float pitch) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playRecord(SoundEvent soundIn, BlockPos pos) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addParticle(IParticleData particleData, boolean alwaysRender, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addParticle(IParticleData particleData, boolean ignoreRange, boolean minimizeLevel, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityAdded(Entity entityIn) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityRemoved(Entity entityIn) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcastSound(int soundID, BlockPos pos, int data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playEvent(EntityPlayer player, int type, BlockPos blockPosIn, int data) {
|
||||
|
||||
}
|
||||
|
||||
//TODO 1.14
|
||||
//Sends breaking progress for all coordinates to renderglobal, so all blocks get visually broken
|
||||
@Override
|
||||
public void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
|
||||
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(mc.player);
|
||||
if (!BuildModifiers.isEnabled(modifierSettings, pos)) return;
|
||||
|
||||
List<BlockPos> coordinates = BuildModifiers.findCoordinates(mc.player, pos);
|
||||
for (int i = 1; i < coordinates.size(); i++) {
|
||||
BlockPos coordinate = coordinates.get(i);
|
||||
if (SurvivalHelper.canBreak(mc.world, mc.player, coordinate)) {
|
||||
//Send i as entity id because only one block can be broken per id
|
||||
//Unless i happens to be the player id, then take something else
|
||||
int fakeId = mc.player.getEntityId() != i ? i : coordinates.size();
|
||||
mc.renderGlobal.sendBlockBreakProgress(fakeId, coordinate, progress);
|
||||
}
|
||||
}
|
||||
}
|
||||
// @Override
|
||||
// public void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress) {
|
||||
// Minecraft mc = Minecraft.getInstance();
|
||||
//
|
||||
// ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(mc.player);
|
||||
// if (!BuildModifiers.isEnabled(modifierSettings, pos)) return;
|
||||
//
|
||||
// List<BlockPos> coordinates = BuildModifiers.findCoordinates(mc.player, pos);
|
||||
// for (int i = 1; i < coordinates.size(); i++) {
|
||||
// BlockPos coordinate = coordinates.get(i);
|
||||
// if (SurvivalHelper.canBreak(mc.world, mc.player, coordinate)) {
|
||||
// //Send i as entity id because only one block can be broken per id
|
||||
// //Unless i happens to be the player id, then take something else
|
||||
// int fakeId = mc.player.getEntityId() != i ? i : coordinates.size();
|
||||
// mc.renderGlobal.sendBlockBreakProgress(fakeId, coordinate, progress);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
*/
|
||||
package nl.requios.effortlessbuilding.render;
|
||||
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import nl.requios.effortlessbuilding.BuildConfig;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
@@ -74,7 +73,15 @@ public final class ShaderHandler {
|
||||
}
|
||||
|
||||
public static boolean doUseShaders() {
|
||||
return BuildConfig.visuals.useShaders.get() && OpenGlHelper.shadersSupported;
|
||||
//Extracted from OpenGLHelper in 1.13 and earlier
|
||||
//Can probably be simplified
|
||||
GLCapabilities glcapabilities = GL.getCapabilities();
|
||||
boolean openGL14 = glcapabilities.OpenGL14 || glcapabilities.GL_EXT_blend_func_separate;
|
||||
boolean openGL21 = glcapabilities.OpenGL21;
|
||||
boolean framebufferSupported = openGL14 && (glcapabilities.GL_ARB_framebuffer_object || glcapabilities.GL_EXT_framebuffer_object || glcapabilities.OpenGL30);
|
||||
boolean shadersAvailable = openGL21 || glcapabilities.GL_ARB_vertex_shader && glcapabilities.GL_ARB_fragment_shader && glcapabilities.GL_ARB_shader_objects;
|
||||
boolean shadersSupported = framebufferSupported && shadersAvailable;
|
||||
return BuildConfig.visuals.useShaders.get() && shadersSupported;
|
||||
}
|
||||
|
||||
private static int createProgram(String s, int sides) {
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
{
|
||||
"effortlessbuilding.screen.modifier_settings": "Modifier Settings",
|
||||
"effortlessbuilding.screen.radial_menu": "Build Modes",
|
||||
"effortlessbuilding.screen.randomizer_bag": "Randomizer Bag",
|
||||
|
||||
"key.effortlessbuilding.category": "Effortless Building",
|
||||
"key.effortlessbuilding.hud.desc": "Modifier Menu",
|
||||
"key.effortlessbuilding.replace.desc": "Toggle QuickReplace",
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"conditions": {
|
||||
"enable_reach_upgrades": "nl.requios.effortlessbuilding.helper.ReachConditionFactory"
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,4 @@
|
||||
{
|
||||
"conditions": [{
|
||||
"type": "effortlessbuilding:enable_reach_upgrades"
|
||||
}],
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
" S",
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
{
|
||||
"conditions": [{
|
||||
"type": "effortlessbuilding:enable_reach_upgrades"
|
||||
}],
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
" M",
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
{
|
||||
"conditions": [{
|
||||
"type": "effortlessbuilding:enable_reach_upgrades"
|
||||
}],
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
" FE",
|
||||
|
||||
Reference in New Issue
Block a user