Initial 1.14 commit. Migrated using xml mapping (in User\.IntelliJIdea2019.3\config\migration). Went through all classes to fix minor issues.

Main tasks left to do: screens, blockBreak animation, ClientProxy/BlockRayTraceResult.
This commit is contained in:
Christian Knaapen
2019-12-04 20:43:40 +01:00
parent 1e51589bde
commit ac429ca64e
70 changed files with 923 additions and 988 deletions

View File

@@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse' apply plugin: 'eclipse'
apply plugin: 'maven-publish' apply plugin: 'maven-publish'
version = '1.13.2-2.15' version = '1.14.4-2.15'
group = 'nl.requios.effortlessbuilding' // http://maven.apache.org/guides/mini/guide-naming-conventions.html group = 'nl.requios.effortlessbuilding' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'effortlessbuilding' archivesBaseName = 'effortlessbuilding'
@@ -25,10 +25,10 @@ minecraft {
// stable_# Stables are built at the discretion of the MCP team. // stable_# Stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not always work. // 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. // 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. // 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. // Default run configurations.
// These can be tweaked, removed, or duplicated as needed. // 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 // 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. // 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. // 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.. // You may put jars on which you depend on in ./libs or you may define them like so..
// compile "some.group:artifact:version:classifier" // compile "some.group:artifact:version:classifier"

View File

@@ -1,10 +1,10 @@
package nl.requios.effortlessbuilding; package nl.requios.effortlessbuilding;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.capabilities.CapabilityManager; import net.minecraftforge.common.capabilities.CapabilityManager;
import net.minecraftforge.common.crafting.CraftingHelper; import net.minecraftforge.common.crafting.CraftingHelper;
@@ -20,7 +20,6 @@ import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent; import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent; import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.network.NetworkRegistry;
import nl.requios.effortlessbuilding.capability.ModeCapabilityManager; import nl.requios.effortlessbuilding.capability.ModeCapabilityManager;
import nl.requios.effortlessbuilding.capability.ModifierCapabilityManager; import nl.requios.effortlessbuilding.capability.ModifierCapabilityManager;
import nl.requios.effortlessbuilding.command.CommandReach; import nl.requios.effortlessbuilding.command.CommandReach;
@@ -35,7 +34,6 @@ import nl.requios.effortlessbuilding.network.PacketHandler;
import nl.requios.effortlessbuilding.proxy.ClientProxy; import nl.requios.effortlessbuilding.proxy.ClientProxy;
import nl.requios.effortlessbuilding.proxy.IProxy; import nl.requios.effortlessbuilding.proxy.IProxy;
import nl.requios.effortlessbuilding.proxy.ServerProxy; import nl.requios.effortlessbuilding.proxy.ServerProxy;
import nl.requios.effortlessbuilding.render.ShaderHandler;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@@ -104,7 +102,8 @@ public class EffortlessBuilding
//TODO 1.13 config //TODO 1.13 config
// ConfigManager.sync(MODID, Config.Type.INSTANCE); // ConfigManager.sync(MODID, Config.Type.INSTANCE);
ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.GUIFACTORY, () -> RandomizerBagGuiHandler::openGui); //TODO 1.14 GUI
// ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.GUIFACTORY, () -> RandomizerBagGuiHandler::openGui);
proxy.setup(event); proxy.setup(event);
@@ -143,11 +142,11 @@ public class EffortlessBuilding
logger.info(msg); logger.info(msg);
} }
public static void log(EntityPlayer player, String msg){ public static void log(PlayerEntity player, String msg){
log(player, msg, false); log(player, msg, false);
} }
public static void log(EntityPlayer player, String msg, boolean actionBar){ public static void log(PlayerEntity player, String msg, boolean actionBar){
player.sendStatusMessage(new TextComponentString(msg), actionBar); player.sendStatusMessage(new StringTextComponent(msg), actionBar);
} }
} }

View File

@@ -1,16 +1,13 @@
package nl.requios.effortlessbuilding; 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.Entity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.init.Blocks;
import net.minecraft.stats.Stat;
import net.minecraft.stats.StatList;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.event.AttachCapabilitiesEvent;
import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.event.world.BlockEvent;
@@ -33,15 +30,13 @@ import nl.requios.effortlessbuilding.network.RequestLookAtMessage;
import java.util.List; import java.util.List;
import static net.minecraftforge.fml.common.gameevent.PlayerEvent.*;
@Mod.EventBusSubscriber @Mod.EventBusSubscriber
public class EventHandler public class EventHandler
{ {
@SubscribeEvent @SubscribeEvent
public static void attachCapabilities(AttachCapabilitiesEvent<Entity> event) { 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_modifier"), new ModifierCapabilityManager.Provider());
event.addCapability(new ResourceLocation(EffortlessBuilding.MODID, "build_mode"), new ModeCapabilityManager.Provider()); event.addCapability(new ResourceLocation(EffortlessBuilding.MODID, "build_mode"), new ModeCapabilityManager.Provider());
} }
@@ -67,10 +62,10 @@ public class EventHandler
public static void onBlockPlaced(BlockEvent.EntityPlaceEvent event) { public static void onBlockPlaced(BlockEvent.EntityPlaceEvent event) {
if (event.getWorld().isRemote()) return; if (event.getWorld().isRemote()) return;
if (!(event.getEntity() instanceof EntityPlayer)) return; if (!(event.getEntity() instanceof PlayerEntity)) return;
//Cancel event if necessary //Cancel event if necessary
EntityPlayerMP player = ((EntityPlayerMP) event.getEntity()); ServerPlayerEntity player = ((ServerPlayerEntity) event.getEntity());
BuildModes.BuildModeEnum buildMode = ModeSettingsManager.getModeSettings(player).getBuildMode(); BuildModes.BuildModeEnum buildMode = ModeSettingsManager.getModeSettings(player).getBuildMode();
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player); ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
@@ -112,7 +107,7 @@ public class EventHandler
BuildModes.onBlockBroken(event.getPlayer(), event.getPos(), false); BuildModes.onBlockBroken(event.getPlayer(), event.getPos(), false);
//Add to undo stack in client //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 +116,7 @@ public class EventHandler
//Disable if config says so //Disable if config says so
if (!BuildConfig.survivalBalancers.increasedMiningTime.get()) return; if (!BuildConfig.survivalBalancers.increasedMiningTime.get()) return;
EntityPlayer player = event.getEntityPlayer(); PlayerEntity player = event.getEntityPlayer();
World world = player.world; World world = player.world;
BlockPos pos = event.getPos(); BlockPos pos = event.getPos();
@@ -135,7 +130,7 @@ public class EventHandler
for (int i = 1; i < coordinates.size(); i++) { for (int i = 1; i < coordinates.size(); i++) {
BlockPos coordinate = coordinates.get(i); BlockPos coordinate = coordinates.get(i);
//get existing blockstates at those coordinates //get existing blockstates at those coordinates
IBlockState blockState = world.getBlockState(coordinate); BlockState blockState = world.getBlockState(coordinate);
//add hardness for each blockstate, if can break //add hardness for each blockstate, if can break
if (SurvivalHelper.canBreak(world, player, coordinate)) if (SurvivalHelper.canBreak(world, player, coordinate))
totalBlockHardness += blockState.getBlockHardness(world, coordinate); totalBlockHardness += blockState.getBlockHardness(world, coordinate);
@@ -154,31 +149,31 @@ public class EventHandler
} }
@SubscribeEvent @SubscribeEvent
public static void onPlayerLoggedIn(PlayerLoggedInEvent event) { public static void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
EntityPlayer player = event.getPlayer(); PlayerEntity player = event.getPlayer();
ModifierSettingsManager.handleNewPlayer(player); ModifierSettingsManager.handleNewPlayer(player);
ModeSettingsManager.handleNewPlayer(player); ModeSettingsManager.handleNewPlayer(player);
} }
@SubscribeEvent @SubscribeEvent
public static void onPlayerLoggedOut(PlayerLoggedOutEvent event) { public static void onPlayerLoggedOut(PlayerEvent.PlayerLoggedOutEvent event) {
EntityPlayer player = event.getPlayer(); PlayerEntity player = event.getPlayer();
if (player.getEntityWorld().isRemote) return; if (player.getEntityWorld().isRemote) return;
UndoRedo.clear(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 @SubscribeEvent
public static void onPlayerRespawn(PlayerRespawnEvent event) { public static void onPlayerRespawn(PlayerEvent.PlayerRespawnEvent event) {
EntityPlayer player = event.getPlayer(); PlayerEntity player = event.getPlayer();
ModifierSettingsManager.handleNewPlayer(player); ModifierSettingsManager.handleNewPlayer(player);
ModeSettingsManager.handleNewPlayer(player); ModeSettingsManager.handleNewPlayer(player);
} }
@SubscribeEvent @SubscribeEvent
public static void onPlayerChangedDimension(PlayerChangedDimensionEvent event) { public static void onPlayerChangedDimension(PlayerEvent.PlayerChangedDimensionEvent event) {
EntityPlayer player = event.getPlayer(); PlayerEntity player = event.getPlayer();
if (player.getEntityWorld().isRemote) return; if (player.getEntityWorld().isRemote) return;
//Set build mode to normal //Set build mode to normal
@@ -197,16 +192,16 @@ public class EventHandler
ModeSettingsManager.handleNewPlayer(player); ModeSettingsManager.handleNewPlayer(player);
UndoRedo.clear(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 @SubscribeEvent
public static void onPlayerClone(PlayerEvent.Clone event) { public static void onPlayerClone(PlayerEvent.Clone event) {
//Attach capabilities on death, otherwise crash //Attach capabilities on death, otherwise crash
EntityPlayer oldPlayer = event.getOriginal(); PlayerEntity oldPlayer = event.getOriginal();
oldPlayer.revive(); oldPlayer.revive();
EntityPlayer newPlayer = event.getEntityPlayer(); PlayerEntity newPlayer = event.getEntityPlayer();
ModifierSettingsManager.setModifierSettings(newPlayer, ModifierSettingsManager.getModifierSettings(oldPlayer)); ModifierSettingsManager.setModifierSettings(newPlayer, ModifierSettingsManager.getModifierSettings(oldPlayer));
ModeSettingsManager.setModeSettings(newPlayer, ModeSettingsManager.getModeSettings(oldPlayer)); ModeSettingsManager.setModeSettings(newPlayer, ModeSettingsManager.getModeSettings(oldPlayer));
} }

View File

@@ -2,7 +2,7 @@ package nl.requios.effortlessbuilding;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock; import net.minecraft.item.BlockItem;
import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
@@ -24,7 +24,7 @@ public class ModEventHandler {
for (Block block : EffortlessBuilding.BLOCKS) 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()));
} }
} }
} }

View File

@@ -1,13 +1,12 @@
package nl.requios.effortlessbuilding.buildmode; package nl.requios.effortlessbuilding.buildmode;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.EnumFacing; import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import java.util.Dictionary; import java.util.Dictionary;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.List;
import java.util.UUID; import java.util.UUID;
public abstract class BaseBuildMode implements IBuildMode { 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> rightClickClientTable = new Hashtable<>();
protected Dictionary<UUID, Integer> rightClickServerTable = new Hashtable<>(); protected Dictionary<UUID, Integer> rightClickServerTable = new Hashtable<>();
protected Dictionary<UUID, BlockPos> firstPosTable = 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<>(); protected Dictionary<UUID, Vec3d> hitVecTable = new Hashtable<>();
@Override @Override
public void initialize(EntityPlayer player) { public void initialize(PlayerEntity player) {
rightClickClientTable.put(player.getUniqueID(), 0); rightClickClientTable.put(player.getUniqueID(), 0);
rightClickServerTable.put(player.getUniqueID(), 0); rightClickServerTable.put(player.getUniqueID(), 0);
firstPosTable.put(player.getUniqueID(), BlockPos.ORIGIN); firstPosTable.put(player.getUniqueID(), BlockPos.ZERO);
sideHitTable.put(player.getUniqueID(), EnumFacing.UP); sideHitTable.put(player.getUniqueID(), Direction.UP);
hitVecTable.put(player.getUniqueID(), Vec3d.ZERO); hitVecTable.put(player.getUniqueID(), Vec3d.ZERO);
} }
@Override @Override
public EnumFacing getSideHit(EntityPlayer player) { public Direction getSideHit(PlayerEntity player) {
return sideHitTable.get(player.getUniqueID()); return sideHitTable.get(player.getUniqueID());
} }
@Override @Override
public Vec3d getHitVec(EntityPlayer player) { public Vec3d getHitVec(PlayerEntity player) {
return hitVecTable.get(player.getUniqueID()); return hitVecTable.get(player.getUniqueID());
} }
} }

View File

@@ -1,9 +1,9 @@
package nl.requios.effortlessbuilding.buildmode; package nl.requios.effortlessbuilding.buildmode;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.EnumFacing; import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos; 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.RayTraceResult;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import nl.requios.effortlessbuilding.EffortlessBuilding; import nl.requios.effortlessbuilding.EffortlessBuilding;
@@ -26,8 +26,8 @@ public class BuildModes {
//Static variables are shared between client and server in singleplayer //Static variables are shared between client and server in singleplayer
//We need them separate //We need them separate
public static Dictionary<EntityPlayer, Boolean> currentlyBreakingClient = new Hashtable<>(); public static Dictionary<PlayerEntity, Boolean> currentlyBreakingClient = new Hashtable<>();
public static Dictionary<EntityPlayer, Boolean> currentlyBreakingServer = new Hashtable<>(); public static Dictionary<PlayerEntity, Boolean> currentlyBreakingServer = new Hashtable<>();
public enum BuildModeEnum { public enum BuildModeEnum {
NORMAL("effortlessbuilding.mode.normal", new Normal()), 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 //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 //The server could keep track of all raytraceresults but this might lag with many players
//Raytraceresult is needed for sideHit and hitVec //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 //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)) { if (currentlyBreaking.get(player) != null && currentlyBreaking.get(player)) {
//Cancel breaking //Cancel breaking
initializeMode(player); initializeMode(player);
@@ -112,7 +112,7 @@ public class BuildModes {
coordinates = coordinates.subList(0, limit); coordinates = coordinates.subList(0, limit);
} }
EnumFacing sideHit = buildMode.instance.getSideHit(player); Direction sideHit = buildMode.instance.getSideHit(player);
if (sideHit == null) sideHit = message.getSideHit(); if (sideHit == null) sideHit = message.getSideHit();
Vec3d hitVec = buildMode.instance.getHitVec(player); 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 //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; BlockPos startPos = message.isBlockHit() ? message.getBlockPos() : null;
onBlockBroken(player, startPos, true); 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 //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)) { if (currentlyBreaking.get(player) != null && !currentlyBreaking.get(player)) {
//Cancel placing //Cancel placing
initializeMode(player); initializeMode(player);
@@ -153,7 +153,7 @@ public class BuildModes {
//Get coordinates //Get coordinates
BuildModeEnum buildMode = modeSettings.getBuildMode(); 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()) { if (coordinates.isEmpty()) {
currentlyBreaking.put(player, true); currentlyBreaking.put(player, true);
@@ -168,7 +168,7 @@ public class BuildModes {
currentlyBreaking.remove(player); 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<>(); List<BlockPos> coordinates = new ArrayList<>();
ModeSettingsManager.ModeSettings modeSettings = ModeSettingsManager.getModeSettings(player); ModeSettingsManager.ModeSettings modeSettings = ModeSettingsManager.getModeSettings(player);
@@ -177,27 +177,27 @@ public class BuildModes {
return coordinates; return coordinates;
} }
public static void initializeMode(EntityPlayer player) { public static void initializeMode(PlayerEntity player) {
//Resetting mode, so not placing or breaking //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); currentlyBreaking.remove(player);
ModeSettingsManager.getModeSettings(player).getBuildMode().instance.initialize(player); ModeSettingsManager.getModeSettings(player).getBuildMode().instance.initialize(player);
} }
public static boolean isCurrentlyPlacing(EntityPlayer player) { public static boolean isCurrentlyPlacing(PlayerEntity player) {
Dictionary<EntityPlayer, Boolean> currentlyBreaking = player.world.isRemote ? currentlyBreakingClient : currentlyBreakingServer; Dictionary<PlayerEntity, Boolean> currentlyBreaking = player.world.isRemote ? currentlyBreakingClient : currentlyBreakingServer;
return currentlyBreaking.get(player) != null && !currentlyBreaking.get(player); return currentlyBreaking.get(player) != null && !currentlyBreaking.get(player);
} }
public static boolean isCurrentlyBreaking(EntityPlayer player) { public static boolean isCurrentlyBreaking(PlayerEntity player) {
Dictionary<EntityPlayer, Boolean> currentlyBreaking = player.world.isRemote ? currentlyBreakingClient : currentlyBreakingServer; Dictionary<PlayerEntity, Boolean> currentlyBreaking = player.world.isRemote ? currentlyBreakingClient : currentlyBreakingServer;
return currentlyBreaking.get(player) != null && currentlyBreaking.get(player); return currentlyBreaking.get(player) != null && currentlyBreaking.get(player);
} }
//Either placing or breaking //Either placing or breaking
public static boolean isActive(EntityPlayer player) { public static boolean isActive(PlayerEntity player) {
Dictionary<EntityPlayer, Boolean> currentlyBreaking = player.world.isRemote ? currentlyBreakingClient : currentlyBreakingServer; Dictionary<PlayerEntity, Boolean> currentlyBreaking = player.world.isRemote ? currentlyBreakingClient : currentlyBreakingServer;
return currentlyBreaking.get(player) != null; return currentlyBreaking.get(player) != null;
} }
@@ -229,13 +229,14 @@ public class BuildModes {
return new Vec3d(x, y, z); 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; boolean intersects = false;
if (!skipRaytrace) { if (!skipRaytrace) {
//collision within a 1 block radius to selected is fine //collision within a 1 block radius to selected is fine
RayTraceResult rayTraceResult = player.world.rayTraceBlocks(start, lineBound, RayTraceFluidMode.NEVER, true, false); RayTraceContext rayTraceContext = new RayTraceContext(start, lineBound, RayTraceContext.BlockMode.COLLIDER, RayTraceContext.FluidMode.NONE, player);
intersects = rayTraceResult != null && rayTraceResult.type == RayTraceResult.Type.BLOCK && RayTraceResult rayTraceResult = player.world.rayTraceBlocks(rayTraceContext);
planeBound.subtract(rayTraceResult.hitVec).lengthSquared() > 4; intersects = rayTraceResult != null && rayTraceResult.getType() == RayTraceResult.Type.BLOCK &&
planeBound.subtract(rayTraceResult.getHitVec()).lengthSquared() > 4;
} }
return planeBound.subtract(start).dotProduct(look) > 0 && return planeBound.subtract(start).dotProduct(look) > 0 &&

View File

@@ -1,7 +1,7 @@
package nl.requios.effortlessbuilding.buildmode; package nl.requios.effortlessbuilding.buildmode;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.EnumFacing; import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
@@ -10,16 +10,16 @@ import java.util.List;
public interface IBuildMode { public interface IBuildMode {
//Fired when a player selects a buildmode and when it needs to initializeMode //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 //Fired when a block would be placed
//Return a list of coordinates where you want to place blocks //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 //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);
} }

View File

@@ -1,6 +1,6 @@
package nl.requios.effortlessbuilding.buildmode; package nl.requios.effortlessbuilding.buildmode;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TextFormatting;
import nl.requios.effortlessbuilding.EffortlessBuilding; import nl.requios.effortlessbuilding.EffortlessBuilding;
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager; import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
@@ -110,7 +110,7 @@ public class ModeOptions {
} }
//Called on both client and server //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; if (action == null) return;
switch (action) { switch (action) {

View File

@@ -1,7 +1,7 @@
package nl.requios.effortlessbuilding.buildmode; package nl.requios.effortlessbuilding.buildmode;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.network.PacketDistributor; import net.minecraftforge.fml.network.PacketDistributor;
@@ -19,7 +19,7 @@ public class ModeSettingsManager {
//Retrieves the buildsettings of a player through the modifierCapability capability //Retrieves the buildsettings of a player through the modifierCapability capability
//Never returns null //Never returns null
@Nonnull @Nonnull
public static ModeSettings getModeSettings(EntityPlayer player) { public static ModeSettings getModeSettings(PlayerEntity player) {
LazyOptional<ModeCapabilityManager.IModeCapability> modeCapability = LazyOptional<ModeCapabilityManager.IModeCapability> modeCapability =
player.getCapability(ModeCapabilityManager.modeCapability, null); player.getCapability(ModeCapabilityManager.modeCapability, null);
@@ -37,7 +37,7 @@ public class ModeSettingsManager {
// throw new IllegalArgumentException("Player does not have modeCapability capability"); // 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) { if (player == null) {
EffortlessBuilding.log("Cannot set buildmode settings, player is null"); EffortlessBuilding.log("Cannot set buildmode settings, player is null");
return; 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); int maxReach = ReachHelper.getMaxReach(player);
String error = ""; 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) //Makes sure player has mode settings (if it doesnt it will create it)
getModeSettings(player); getModeSettings(player);
@@ -92,7 +92,7 @@ public class ModeSettingsManager {
if (!player.world.isRemote) { if (!player.world.isRemote) {
//Send to client //Send to client
ModeSettingsMessage msg = new ModeSettingsMessage(getModeSettings(player)); ModeSettingsMessage msg = new ModeSettingsMessage(getModeSettings(player));
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (EntityPlayerMP) player), msg); PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), msg);
} }
} }
} }

View File

@@ -1,11 +1,9 @@
package nl.requios.effortlessbuilding.buildmode; package nl.requios.effortlessbuilding.buildmode;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.EnumFacing; import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; 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 nl.requios.effortlessbuilding.helper.ReachHelper;
import java.util.*; 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 //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 //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); return BuildModes.isCriteriaValid(start, look, reach, player, skipRaytrace, lineBound, planeBound, distToPlayerSq);
} }
} }
@Override @Override
public void initialize(EntityPlayer player) { public void initialize(PlayerEntity player) {
super.initialize(player); super.initialize(player);
secondPosTable.put(player.getUniqueID(), BlockPos.ORIGIN); secondPosTable.put(player.getUniqueID(), BlockPos.ZERO);
} }
@Override @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<>(); List<BlockPos> list = new ArrayList<>();
Dictionary<UUID, Integer> rightClickTable = player.world.isRemote ? rightClickClientTable : rightClickServerTable; Dictionary<UUID, Integer> rightClickTable = player.world.isRemote ? rightClickClientTable : rightClickServerTable;
@@ -89,7 +87,7 @@ public abstract class ThreeClicksBuildMode extends BaseBuildMode {
} }
@Override @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<>(); List<BlockPos> list = new ArrayList<>();
Dictionary<UUID, Integer> rightClickTable = player.world.isRemote ? rightClickClientTable : rightClickServerTable; Dictionary<UUID, Integer> rightClickTable = player.world.isRemote ? rightClickClientTable : rightClickServerTable;
int rightClickNr = rightClickTable.get(player.getUniqueID()); int rightClickNr = rightClickTable.get(player.getUniqueID());
@@ -158,19 +156,19 @@ public abstract class ThreeClicksBuildMode extends BaseBuildMode {
} }
//Finds the place of the second block pos //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 //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) //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 //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 //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 look = player.getLookVec();
Vec3d start = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ); Vec3d start = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ);

View File

@@ -1,7 +1,7 @@
package nl.requios.effortlessbuilding.buildmode; package nl.requios.effortlessbuilding.buildmode;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.EnumFacing; import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import nl.requios.effortlessbuilding.helper.ReachHelper; import nl.requios.effortlessbuilding.helper.ReachHelper;
@@ -14,7 +14,7 @@ import java.util.UUID;
public abstract class TwoClicksBuildMode extends BaseBuildMode { public abstract class TwoClicksBuildMode extends BaseBuildMode {
@Override @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<>(); List<BlockPos> list = new ArrayList<>();
Dictionary<UUID, Integer> rightClickTable = player.world.isRemote ? rightClickClientTable : rightClickServerTable; Dictionary<UUID, Integer> rightClickTable = player.world.isRemote ? rightClickClientTable : rightClickServerTable;
@@ -44,7 +44,7 @@ public abstract class TwoClicksBuildMode extends BaseBuildMode {
} }
@Override @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<>(); List<BlockPos> list = new ArrayList<>();
Dictionary<UUID, Integer> rightClickTable = player.world.isRemote ? rightClickClientTable : rightClickServerTable; Dictionary<UUID, Integer> rightClickTable = player.world.isRemote ? rightClickClientTable : rightClickServerTable;
int rightClickNr = rightClickTable.get(player.getUniqueID()); 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) //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 //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);
} }

View File

@@ -1,6 +1,6 @@
package nl.requios.effortlessbuilding.buildmode.buildmodes; 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.BlockPos;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import nl.requios.effortlessbuilding.buildmode.TwoClicksBuildMode; import nl.requios.effortlessbuilding.buildmode.TwoClicksBuildMode;
@@ -11,16 +11,16 @@ import java.util.*;
public class Circle extends TwoClicksBuildMode { public class Circle extends TwoClicksBuildMode {
@Override @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); return Floor.findFloor(player, firstPos, skipRaytrace);
} }
@Override @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); 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<>(); List<BlockPos> list = new ArrayList<>();
float centerX = x1; float centerX = x1;

View File

@@ -1,39 +1,35 @@
package nl.requios.effortlessbuilding.buildmode.buildmodes; package nl.requios.effortlessbuilding.buildmode.buildmodes;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos; 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.ModeOptions;
import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode; import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode;
import nl.requios.effortlessbuilding.helper.ReachHelper;
import java.util.*; import java.util.*;
public class Cube extends ThreeClicksBuildMode { public class Cube extends ThreeClicksBuildMode {
@Override @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); return Floor.findFloor(player, firstPos, skipRaytrace);
} }
@Override @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); return findHeight(player, secondPos, skipRaytrace);
} }
@Override @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); return getFloorBlocksUsingCubeFill(player, x1, y1, z1, x2, y2, z2);
} }
@Override @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); 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<>(); List<BlockPos> list = new ArrayList<>();
if (ModeOptions.getCubeFill() == ModeOptions.ActionEnum.CUBE_SKELETON) if (ModeOptions.getCubeFill() == ModeOptions.ActionEnum.CUBE_SKELETON)
@@ -44,7 +40,7 @@ public class Cube extends ThreeClicksBuildMode {
return list; 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<>(); List<BlockPos> list = new ArrayList<>();
switch (ModeOptions.getCubeFill()) { switch (ModeOptions.getCubeFill()) {

View File

@@ -1,6 +1,6 @@
package nl.requios.effortlessbuilding.buildmode.buildmodes; 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.BlockPos;
import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode; import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode;
@@ -10,26 +10,26 @@ import java.util.List;
public class Cylinder extends ThreeClicksBuildMode { public class Cylinder extends ThreeClicksBuildMode {
@Override @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); return Floor.findFloor(player, firstPos, skipRaytrace);
} }
@Override @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); return findHeight(player, secondPos, skipRaytrace);
} }
@Override @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); return Circle.getCircleBlocks(player, x1, y1, z1, x2, y2, z2);
} }
@Override @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); 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<>(); List<BlockPos> list = new ArrayList<>();
//Get circle blocks (using CIRCLE_START and FILL options built-in) //Get circle blocks (using CIRCLE_START and FILL options built-in)

View File

@@ -1,10 +1,9 @@
package nl.requios.effortlessbuilding.buildmode.buildmodes; 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.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode; import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode;
import nl.requios.effortlessbuilding.helper.ReachHelper;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -12,29 +11,29 @@ import java.util.List;
public class DiagonalLine extends ThreeClicksBuildMode { public class DiagonalLine extends ThreeClicksBuildMode {
@Override @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); return Floor.findFloor(player, firstPos, skipRaytrace);
} }
@Override @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); return findHeight(player, secondPos, skipRaytrace);
} }
@Override @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 //Add diagonal line from first to second
return getDiagonalLineBlocks(player, x1, y1, z1, x2, y2, z2, 10); return getDiagonalLineBlocks(player, x1, y1, z1, x2, y2, z2, 10);
} }
@Override @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 //Add diagonal line from first to third
return getDiagonalLineBlocks(player, x1, y1, z1, x3, y3, z3, 10); return getDiagonalLineBlocks(player, x1, y1, z1, x3, y3, z3, 10);
} }
//Add diagonal line from first to second //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<>(); List<BlockPos> list = new ArrayList<>();
Vec3d first = new Vec3d(x1, y1, z1).add(0.5, 0.5, 0.5); Vec3d first = new Vec3d(x1, y1, z1).add(0.5, 0.5, 0.5);

View File

@@ -1,9 +1,8 @@
package nl.requios.effortlessbuilding.buildmode.buildmodes; 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.BlockPos;
import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode; import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode;
import nl.requios.effortlessbuilding.helper.ReachHelper;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -11,27 +10,27 @@ import java.util.List;
public class DiagonalWall extends ThreeClicksBuildMode { public class DiagonalWall extends ThreeClicksBuildMode {
@Override @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); return Floor.findFloor(player, firstPos, skipRaytrace);
} }
@Override @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); return findHeight(player, secondPos, skipRaytrace);
} }
@Override @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); return DiagonalLine.getDiagonalLineBlocks(player, x1, y1, z1, x2, y2, z2, 1);
} }
@Override @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); return getDiagonalWallBlocks(player, x1, y1, z1, x2, y2, z2, x3, y3, z3);
} }
//Add diagonal wall from first to second //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<>(); List<BlockPos> list = new ArrayList<>();
//Get diagonal line blocks //Get diagonal line blocks

View File

@@ -1,6 +1,6 @@
package nl.requios.effortlessbuilding.buildmode.buildmodes; 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.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import nl.requios.effortlessbuilding.buildmode.BuildModes; 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 //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 //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); return BuildModes.isCriteriaValid(start, look, reach, player, skipRaytrace, planeBound, planeBound, distToPlayerSq);
} }
} }
@Override @Override
protected BlockPos findSecondPos(EntityPlayer player, BlockPos firstPos, boolean skipRaytrace) { protected BlockPos findSecondPos(PlayerEntity player, BlockPos firstPos, boolean skipRaytrace) {
return findFloor(player, firstPos, 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 look = player.getLookVec();
Vec3d start = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ); Vec3d start = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ);
@@ -58,11 +58,11 @@ public class Floor extends TwoClicksBuildMode {
} }
@Override @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); 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<>(); List<BlockPos> list = new ArrayList<>();
if (ModeOptions.getFill() == ModeOptions.ActionEnum.FULL) if (ModeOptions.getFill() == ModeOptions.ActionEnum.FULL)

View File

@@ -1,6 +1,6 @@
package nl.requios.effortlessbuilding.buildmode.buildmodes; 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.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import nl.requios.effortlessbuilding.buildmode.BuildModes; 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 //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 //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); return BuildModes.isCriteriaValid(start, look, reach, player, skipRaytrace, lineBound, planeBound, distToPlayerSq);
} }
@@ -55,11 +55,11 @@ public class Line extends TwoClicksBuildMode {
} }
@Override @Override
protected BlockPos findSecondPos(EntityPlayer player, BlockPos firstPos, boolean skipRaytrace) { protected BlockPos findSecondPos(PlayerEntity player, BlockPos firstPos, boolean skipRaytrace) {
return findLine(player, firstPos, 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 look = player.getLookVec();
Vec3d start = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ); Vec3d start = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ);
@@ -109,11 +109,11 @@ public class Line extends TwoClicksBuildMode {
} }
@Override @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); 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<>(); List<BlockPos> list = new ArrayList<>();
if (x1 != x2) { if (x1 != x2) {

View File

@@ -1,7 +1,7 @@
package nl.requios.effortlessbuilding.buildmode.buildmodes; package nl.requios.effortlessbuilding.buildmode.buildmodes;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.EnumFacing; import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import nl.requios.effortlessbuilding.buildmode.IBuildMode; import nl.requios.effortlessbuilding.buildmode.IBuildMode;
@@ -11,31 +11,31 @@ import java.util.List;
public class Normal implements IBuildMode { public class Normal implements IBuildMode {
@Override @Override
public void initialize(EntityPlayer player) { public void initialize(PlayerEntity player) {
} }
@Override @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<>(); List<BlockPos> list = new ArrayList<>();
if (blockPos != null) list.add(blockPos); if (blockPos != null) list.add(blockPos);
return list; return list;
} }
@Override @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<>(); List<BlockPos> list = new ArrayList<>();
if (blockPos != null) list.add(blockPos); if (blockPos != null) list.add(blockPos);
return list; return list;
} }
@Override @Override
public EnumFacing getSideHit(EntityPlayer player) { public Direction getSideHit(PlayerEntity player) {
return null; return null;
} }
@Override @Override
public Vec3d getHitVec(EntityPlayer player) { public Vec3d getHitVec(PlayerEntity player) {
return null; return null;
} }
} }

View File

@@ -1,7 +1,7 @@
package nl.requios.effortlessbuilding.buildmode.buildmodes; package nl.requios.effortlessbuilding.buildmode.buildmodes;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.EnumFacing; import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import nl.requios.effortlessbuilding.buildmode.IBuildMode; import nl.requios.effortlessbuilding.buildmode.IBuildMode;
@@ -11,31 +11,31 @@ import java.util.List;
public class NormalPlus implements IBuildMode { public class NormalPlus implements IBuildMode {
@Override @Override
public void initialize(EntityPlayer player) { public void initialize(PlayerEntity player) {
} }
@Override @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<>(); List<BlockPos> list = new ArrayList<>();
if (blockPos != null) list.add(blockPos); if (blockPos != null) list.add(blockPos);
return list; return list;
} }
@Override @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<>(); List<BlockPos> list = new ArrayList<>();
if (blockPos != null) list.add(blockPos); if (blockPos != null) list.add(blockPos);
return list; return list;
} }
@Override @Override
public EnumFacing getSideHit(EntityPlayer player) { public Direction getSideHit(PlayerEntity player) {
return null; return null;
} }
@Override @Override
public Vec3d getHitVec(EntityPlayer player) { public Vec3d getHitVec(PlayerEntity player) {
return null; return null;
} }
} }

View File

@@ -1,6 +1,6 @@
package nl.requios.effortlessbuilding.buildmode.buildmodes; 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.BlockPos;
import nl.requios.effortlessbuilding.buildmode.ModeOptions; import nl.requios.effortlessbuilding.buildmode.ModeOptions;
import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode; import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode;
@@ -12,27 +12,27 @@ import java.util.List;
public class SlopeFloor extends ThreeClicksBuildMode { public class SlopeFloor extends ThreeClicksBuildMode {
@Override @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); return Floor.findFloor(player, firstPos, skipRaytrace);
} }
@Override @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); return findHeight(player, secondPos, skipRaytrace);
} }
@Override @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); return Floor.getFloorBlocks(player, x1, y1, z1, x2, y2, z2);
} }
@Override @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); return getSlopeFloorBlocks(player, x1, y1, z1, x2, y2, z2, x3, y3, z3);
} }
//Add slope floor from first to second //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<>(); List<BlockPos> list = new ArrayList<>();
int axisLimit = ReachHelper.getMaxBlocksPerAxis(player); int axisLimit = ReachHelper.getMaxBlocksPerAxis(player);

View File

@@ -1,6 +1,6 @@
package nl.requios.effortlessbuilding.buildmode.buildmodes; 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.BlockPos;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import nl.requios.effortlessbuilding.buildmode.ModeOptions; import nl.requios.effortlessbuilding.buildmode.ModeOptions;
@@ -12,26 +12,26 @@ import java.util.List;
public class Sphere extends ThreeClicksBuildMode { public class Sphere extends ThreeClicksBuildMode {
@Override @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); return Floor.findFloor(player, firstPos, skipRaytrace);
} }
@Override @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); return findHeight(player, secondPos, skipRaytrace);
} }
@Override @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); return Circle.getCircleBlocks(player, x1, y1, z1, x2, y2, z2);
} }
@Override @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); 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<>(); List<BlockPos> list = new ArrayList<>();
float centerX = x1; float centerX = x1;

View File

@@ -1,6 +1,6 @@
package nl.requios.effortlessbuilding.buildmode.buildmodes; 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.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import nl.requios.effortlessbuilding.buildmode.BuildModes; 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 //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 //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); return BuildModes.isCriteriaValid(start, look, reach, player, skipRaytrace, planeBound, planeBound, distToPlayerSq);
} }
} }
@Override @Override
protected BlockPos findSecondPos(EntityPlayer player, BlockPos firstPos, boolean skipRaytrace) { protected BlockPos findSecondPos(PlayerEntity player, BlockPos firstPos, boolean skipRaytrace) {
return findWall(player, firstPos, 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 look = player.getLookVec();
Vec3d start = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ); Vec3d start = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ);
@@ -76,11 +76,11 @@ public class Wall extends TwoClicksBuildMode {
} }
@Override @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); 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<>(); List<BlockPos> list = new ArrayList<>();
if (x1 == x2) { if (x1 == x2) {

View File

@@ -1,10 +1,10 @@
package nl.requios.effortlessbuilding.buildmodifier; package nl.requios.effortlessbuilding.buildmodifier;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing; import net.minecraft.util.Direction;
import net.minecraft.util.EnumHand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3i; import net.minecraft.util.math.Vec3i;
@@ -18,7 +18,7 @@ public class Array {
public static class ArraySettings{ public static class ArraySettings{
public boolean enabled = false; public boolean enabled = false;
public BlockPos offset = BlockPos.ORIGIN; public BlockPos offset = BlockPos.ZERO;
public int count = 5; public int count = 5;
public ArraySettings() { 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<>(); List<BlockPos> coordinates = new ArrayList<>();
//find arraysettings for the player //find arraysettings for the player
@@ -59,8 +59,8 @@ public class Array {
return coordinates; return coordinates;
} }
public static List<IBlockState> findBlockStates(EntityPlayer player, BlockPos startPos, IBlockState blockState, ItemStack itemStack, List<ItemStack> itemStacks) { public static List<BlockState> findBlockStates(PlayerEntity player, BlockPos startPos, BlockState blockState, ItemStack itemStack, List<ItemStack> itemStacks) {
List<IBlockState> blockStates = new ArrayList<>(); List<BlockState> blockStates = new ArrayList<>();
//find arraysettings for the player that placed the block //find arraysettings for the player that placed the block
ArraySettings a = ModifierSettingsManager.getModifierSettings(player).getArraySettings(); ArraySettings a = ModifierSettingsManager.getModifierSettings(player).getArraySettings();
@@ -82,7 +82,7 @@ public class Array {
if (bagInventory != null) { if (bagInventory != null) {
itemStack = ItemRandomizerBag.pickRandomStack(bagInventory); itemStack = ItemRandomizerBag.pickRandomStack(bagInventory);
blockState = BuildModifiers 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, ) //blockState = blockState.getBlock().getStateForPlacement(player.world, pos, )

View File

@@ -1,6 +1,6 @@
package nl.requios.effortlessbuilding.buildmodifier; 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.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
@@ -8,13 +8,13 @@ import java.util.List;
public class BlockSet { public class BlockSet {
private List<BlockPos> coordinates; private List<BlockPos> coordinates;
private List<IBlockState> previousBlockStates; private List<BlockState> previousBlockStates;
private List<IBlockState> newBlockStates; private List<BlockState> newBlockStates;
private Vec3d hitVec; private Vec3d hitVec;
private BlockPos firstPos; private BlockPos firstPos;
private BlockPos secondPos; 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) { BlockPos firstPos, BlockPos secondPos) {
this.coordinates = coordinates; this.coordinates = coordinates;
this.previousBlockStates = previousBlockStates; this.previousBlockStates = previousBlockStates;
@@ -28,11 +28,11 @@ public class BlockSet {
return coordinates; return coordinates;
} }
public List<IBlockState> getPreviousBlockStates() { public List<BlockState> getPreviousBlockStates() {
return previousBlockStates; return previousBlockStates;
} }
public List<IBlockState> getNewBlockStates() { public List<BlockState> getNewBlockStates() {
return newBlockStates; return newBlockStates;
} }

View File

@@ -1,18 +1,19 @@
package nl.requios.effortlessbuilding.buildmodifier; package nl.requios.effortlessbuilding.buildmodifier;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.init.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.item.BlockItem;
import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing; import net.minecraft.item.ItemUseContext;
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.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World; import net.minecraft.world.World;
import nl.requios.effortlessbuilding.EffortlessBuilding;
import nl.requios.effortlessbuilding.compatibility.CompatHelper; import nl.requios.effortlessbuilding.compatibility.CompatHelper;
import nl.requios.effortlessbuilding.helper.InventoryHelper; import nl.requios.effortlessbuilding.helper.InventoryHelper;
import nl.requios.effortlessbuilding.helper.SurvivalHelper; import nl.requios.effortlessbuilding.helper.SurvivalHelper;
@@ -24,7 +25,7 @@ import java.util.*;
public class BuildModifiers { public class BuildModifiers {
//Called from BuildModes //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; World world = player.world;
ItemRandomizerBag.renewRandomness(); ItemRandomizerBag.renewRandomness();
@@ -34,14 +35,14 @@ public class BuildModifiers {
//find coordinates and blockstates //find coordinates and blockstates
List<BlockPos> coordinates = findCoordinates(player, startCoordinates); List<BlockPos> coordinates = findCoordinates(player, startCoordinates);
List<ItemStack> itemStacks = new ArrayList<>(); 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 //check if valid blockstates
if (blockStates.size() == 0 || coordinates.size() != blockStates.size()) return; if (blockStates.size() == 0 || coordinates.size() != blockStates.size()) return;
//remember previous blockstates for undo //remember previous blockstates for undo
List<IBlockState> previousBlockStates = new ArrayList<>(coordinates.size()); List<BlockState> previousBlockStates = new ArrayList<>(coordinates.size());
List<IBlockState> newBlockStates = new ArrayList<>(coordinates.size()); List<BlockState> newBlockStates = new ArrayList<>(coordinates.size());
for (BlockPos coordinate : coordinates) { for (BlockPos coordinate : coordinates) {
previousBlockStates.add(world.getBlockState(coordinate)); previousBlockStates.add(world.getBlockState(coordinate));
} }
@@ -57,17 +58,17 @@ public class BuildModifiers {
//place blocks //place blocks
for (int i = placeStartPos ? 0 : 1; i < coordinates.size(); i++) { for (int i = placeStartPos ? 0 : 1; i < coordinates.size(); i++) {
BlockPos blockPos = coordinates.get(i); BlockPos blockPos = coordinates.get(i);
IBlockState blockState = blockStates.get(i); BlockState blockState = blockStates.get(i);
ItemStack itemStack = itemStacks.get(i); ItemStack itemStack = itemStacks.get(i);
if (world.isBlockLoaded(blockPos, true)) { if (world.isBlockPresent(blockPos)) {
//check itemstack empty //check itemstack empty
if (itemStack.isEmpty()) { if (itemStack.isEmpty()) {
//try to find new stack, otherwise continue //try to find new stack, otherwise continue
itemStack = InventoryHelper.findItemStackInInventory(player, blockState.getBlock()); itemStack = InventoryHelper.findItemStackInInventory(player, blockState.getBlock());
if (itemStack.isEmpty()) continue; 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; World world = player.world;
List<BlockPos> coordinates = findCoordinates(player, startCoordinates); List<BlockPos> coordinates = findCoordinates(player, startCoordinates);
@@ -99,8 +100,8 @@ public class BuildModifiers {
if (coordinates.isEmpty()) return; if (coordinates.isEmpty()) return;
//remember previous blockstates for undo //remember previous blockstates for undo
List<IBlockState> previousBlockStates = new ArrayList<>(coordinates.size()); List<BlockState> previousBlockStates = new ArrayList<>(coordinates.size());
List<IBlockState> newBlockStates = new ArrayList<>(coordinates.size()); List<BlockState> newBlockStates = new ArrayList<>(coordinates.size());
for (BlockPos coordinate : coordinates) { for (BlockPos coordinate : coordinates) {
previousBlockStates.add(world.getBlockState(coordinate)); previousBlockStates.add(world.getBlockState(coordinate));
} }
@@ -122,7 +123,7 @@ public class BuildModifiers {
//break all those blocks //break all those blocks
for (int i = breakStartPos ? 0 : 1; i < coordinates.size(); i++) { for (int i = breakStartPos ? 0 : 1; i < coordinates.size(); i++) {
BlockPos coordinate = coordinates.get(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) { if (!onlyInstaBreaking || world.getBlockState(coordinate).getBlockHardness(world, coordinate) == 0f) {
SurvivalHelper.breakBlock(world, player, coordinate, false); 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<>(); List<BlockPos> coordinates = new ArrayList<>();
//Add current blocks being placed too //Add current blocks being placed too
coordinates.addAll(posList); coordinates.addAll(posList);
@@ -168,18 +169,18 @@ public class BuildModifiers {
return coordinates; 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))); 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) { public static List<BlockState> findBlockStates(PlayerEntity player, List<BlockPos> posList, Vec3d hitVec, Direction facing, List<ItemStack> itemStacks) {
List<IBlockState> blockStates = new ArrayList<>(); List<BlockState> blockStates = new ArrayList<>();
itemStacks.clear(); itemStacks.clear();
//Get itemstack //Get itemstack
ItemStack itemStack = player.getHeldItem(EnumHand.MAIN_HAND); ItemStack itemStack = player.getHeldItem(Hand.MAIN_HAND);
if (itemStack.isEmpty() || !CompatHelper.isItemBlockProxy(itemStack)) { if (itemStack.isEmpty() || !CompatHelper.isItemBlockProxy(itemStack)) {
itemStack = player.getHeldItem(EnumHand.OFF_HAND); itemStack = player.getHeldItem(Hand.OFF_HAND);
} }
if (itemStack.isEmpty() || !CompatHelper.isItemBlockProxy(itemStack)) { if (itemStack.isEmpty() || !CompatHelper.isItemBlockProxy(itemStack)) {
return blockStates; return blockStates;
@@ -187,22 +188,22 @@ public class BuildModifiers {
//Get ItemBlock stack //Get ItemBlock stack
ItemStack itemBlock = ItemStack.EMPTY; ItemStack itemBlock = ItemStack.EMPTY;
if (itemStack.getItem() instanceof ItemBlock) itemBlock = itemStack; if (itemStack.getItem() instanceof BlockItem) itemBlock = itemStack;
else itemBlock = CompatHelper.getItemBlockFromStack(itemStack); else itemBlock = CompatHelper.getItemBlockFromStack(itemStack);
ItemRandomizerBag.resetRandomness(); ItemRandomizerBag.resetRandomness();
//Add blocks in posList first //Add blocks in posList first
for (BlockPos blockPos : posList) { for (BlockPos blockPos : posList) {
if (!(itemStack.getItem() instanceof ItemBlock)) itemBlock = CompatHelper.getItemBlockFromStack(itemStack); if (!(itemStack.getItem() instanceof BlockItem)) itemBlock = CompatHelper.getItemBlockFromStack(itemStack);
IBlockState blockState = getBlockStateFromItem(itemBlock, player, blockPos, facing, hitVec, EnumHand.MAIN_HAND); BlockState blockState = getBlockStateFromItem(itemBlock, player, blockPos, facing, hitVec, Hand.MAIN_HAND);
blockStates.add(blockState); blockStates.add(blockState);
itemStacks.add(itemBlock); itemStacks.add(itemBlock);
} }
for (BlockPos blockPos : posList) { 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(arrayBlockStates);
blockStates.addAll(Mirror.findBlockStates(player, blockPos, blockState, itemStack, itemStacks)); blockStates.addAll(Mirror.findBlockStates(player, blockPos, blockState, itemStack, itemStacks));
blockStates.addAll(RadialMirror.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); List<BlockPos> arrayCoordinates = Array.findCoordinates(player, blockPos);
for (int i = 0; i < arrayCoordinates.size(); i++) { for (int i = 0; i < arrayCoordinates.size(); i++) {
BlockPos coordinate = arrayCoordinates.get(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(Mirror.findBlockStates(player, coordinate, blockState1, itemStack, itemStacks));
blockStates.addAll(RadialMirror.findBlockStates(player, coordinate, blockState1, itemStack, itemStacks)); blockStates.addAll(RadialMirror.findBlockStates(player, coordinate, blockState1, itemStack, itemStacks));
} }
@@ -235,9 +236,8 @@ public class BuildModifiers {
modifierSettings.doQuickReplace(); modifierSettings.doQuickReplace();
} }
public static IBlockState getBlockStateFromItem(ItemStack itemStack, EntityPlayer player, BlockPos blockPos, EnumFacing facing, Vec3d hitVec, EnumHand hand) { public static BlockState getBlockStateFromItem(ItemStack itemStack, PlayerEntity player, BlockPos blockPos, Direction facing, Vec3d hitVec, Hand hand) {
return Block.getBlockFromItem(itemStack.getItem()).getStateForPlacement(new BlockItemUseContext(player.world, player, itemStack, blockPos, facing, return Block.getBlockFromItem(itemStack.getItem()).getStateForPlacement(new BlockItemUseContext(new ItemUseContext(player, hand, new BlockRayTraceResult(hitVec, facing, blockPos, false))));
((float) hitVec.x), ((float) hitVec.y), ((float) hitVec.z)));
} }
//Returns true if equal (or both null) //Returns true if equal (or both null)

View File

@@ -1,16 +1,16 @@
package nl.requios.effortlessbuilding.buildmodifier; package nl.requios.effortlessbuilding.buildmodifier;
import net.minecraft.block.BlockDirectional; import net.minecraft.block.*;
import net.minecraft.block.BlockDispenser; import net.minecraft.block.StairsBlock;
import net.minecraft.block.BlockSlab; import net.minecraft.block.DirectionalBlock;
import net.minecraft.block.BlockStairs; import net.minecraft.block.SlabBlock;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.state.properties.Half; import net.minecraft.state.properties.Half;
import net.minecraft.state.properties.SlabType; import net.minecraft.state.properties.SlabType;
import net.minecraft.util.EnumFacing; import net.minecraft.util.Direction;
import net.minecraft.util.EnumHand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraftforge.items.IItemHandler; 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<>(); List<BlockPos> coordinates = new ArrayList<>();
//find mirrorsettings for the player //find mirrorsettings for the player
@@ -87,8 +87,8 @@ public class Mirror {
coordinates.add(newBlockPos); coordinates.add(newBlockPos);
} }
public static List<IBlockState> findBlockStates(EntityPlayer player, BlockPos startPos, IBlockState blockState, ItemStack itemStack, List<ItemStack> itemStacks) { public static List<BlockState> findBlockStates(PlayerEntity player, BlockPos startPos, BlockState blockState, ItemStack itemStack, List<ItemStack> itemStacks) {
List<IBlockState> blockStates = new ArrayList<>(); List<BlockState> blockStates = new ArrayList<>();
//find mirrorsettings for the player //find mirrorsettings for the player
MirrorSettings m = ModifierSettingsManager.getModifierSettings(player).getMirrorSettings(); MirrorSettings m = ModifierSettingsManager.getModifierSettings(player).getMirrorSettings();
@@ -100,15 +100,15 @@ public class Mirror {
bagInventory = ItemRandomizerBag.getBagInventory(itemStack); bagInventory = ItemRandomizerBag.getBagInventory(itemStack);
} }
if (m.mirrorX) blockStateMirrorX(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, EnumHand.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, EnumHand.MAIN_HAND, blockStates, itemStacks); if (m.mirrorZ) blockStateMirrorZ(player, m, startPos, blockState, bagInventory, itemStack, Hand.MAIN_HAND, blockStates, itemStacks);
return blockStates; return blockStates;
} }
private static void blockStateMirrorX(EntityPlayer player, MirrorSettings m, BlockPos oldBlockPos, IBlockState oldBlockState, private static void blockStateMirrorX(PlayerEntity player, MirrorSettings m, BlockPos oldBlockPos, BlockState oldBlockState,
IItemHandler bagInventory, ItemStack itemStack, EnumHand hand, List<IBlockState> blockStates, List<ItemStack> itemStacks) { IItemHandler bagInventory, ItemStack itemStack, Hand hand, List<BlockState> blockStates, List<ItemStack> itemStacks) {
//find mirror position //find mirror position
double x = m.position.x + (m.position.x - oldBlockPos.getX() - 0.5); double x = m.position.x + (m.position.x - oldBlockPos.getX() - 0.5);
BlockPos newBlockPos = new BlockPos(x, oldBlockPos.getY(), oldBlockPos.getZ()); BlockPos newBlockPos = new BlockPos(x, oldBlockPos.getY(), oldBlockPos.getZ());
@@ -116,11 +116,11 @@ public class Mirror {
//Randomizer bag synergy //Randomizer bag synergy
if (bagInventory != null) { if (bagInventory != null) {
itemStack = ItemRandomizerBag.pickRandomStack(bagInventory); 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 //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 //Store blockstate and itemstack
blockStates.add(newBlockState); blockStates.add(newBlockState);
@@ -130,8 +130,8 @@ public class Mirror {
if (m.mirrorZ) blockStateMirrorZ(player, m, newBlockPos, newBlockState, bagInventory, itemStack, hand, blockStates, itemStacks); 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, private static void blockStateMirrorY(PlayerEntity player, MirrorSettings m, BlockPos oldBlockPos, BlockState oldBlockState,
IItemHandler bagInventory, ItemStack itemStack, EnumHand hand, List<IBlockState> blockStates, List<ItemStack> itemStacks) { IItemHandler bagInventory, ItemStack itemStack, Hand hand, List<BlockState> blockStates, List<ItemStack> itemStacks) {
//find mirror position //find mirror position
double y = m.position.y + (m.position.y - oldBlockPos.getY() - 0.5); double y = m.position.y + (m.position.y - oldBlockPos.getY() - 0.5);
BlockPos newBlockPos = new BlockPos(oldBlockPos.getX(), y, oldBlockPos.getZ()); BlockPos newBlockPos = new BlockPos(oldBlockPos.getX(), y, oldBlockPos.getZ());
@@ -139,11 +139,11 @@ public class Mirror {
//Randomizer bag synergy //Randomizer bag synergy
if (bagInventory != null) { if (bagInventory != null) {
itemStack = ItemRandomizerBag.pickRandomStack(bagInventory); 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 //Find blockstate
IBlockState newBlockState = oldBlockState == null ? null : getVerticalMirror(oldBlockState); BlockState newBlockState = oldBlockState == null ? null : getVerticalMirror(oldBlockState);
//Store blockstate and itemstack //Store blockstate and itemstack
blockStates.add(newBlockState); blockStates.add(newBlockState);
@@ -152,8 +152,8 @@ public class Mirror {
if (m.mirrorZ) blockStateMirrorZ(player, m, newBlockPos, newBlockState, bagInventory, itemStack, hand, blockStates, itemStacks); 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, private static void blockStateMirrorZ(PlayerEntity player, MirrorSettings m, BlockPos oldBlockPos, BlockState oldBlockState,
IItemHandler bagInventory, ItemStack itemStack, EnumHand hand, List<IBlockState> blockStates, List<ItemStack> itemStacks) { IItemHandler bagInventory, ItemStack itemStack, Hand hand, List<BlockState> blockStates, List<ItemStack> itemStacks) {
//find mirror position //find mirror position
double z = m.position.z + (m.position.z - oldBlockPos.getZ() - 0.5); double z = m.position.z + (m.position.z - oldBlockPos.getZ() - 0.5);
BlockPos newBlockPos = new BlockPos(oldBlockPos.getX(), oldBlockPos.getY(), z); BlockPos newBlockPos = new BlockPos(oldBlockPos.getX(), oldBlockPos.getY(), z);
@@ -161,11 +161,11 @@ public class Mirror {
//Randomizer bag synergy //Randomizer bag synergy
if (bagInventory != null) { if (bagInventory != null) {
itemStack = ItemRandomizerBag.pickRandomStack(bagInventory); 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 //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 //Store blockstate and itemstack
blockStates.add(newBlockState); blockStates.add(newBlockState);
@@ -184,42 +184,42 @@ public class Mirror {
return true; return true;
} }
private static IBlockState getVerticalMirror(IBlockState blockState) { private static BlockState getVerticalMirror(BlockState blockState) {
//Stairs //Stairs
if (blockState.getBlock() instanceof BlockStairs) { if (blockState.getBlock() instanceof StairsBlock) {
if (blockState.get(BlockStairs.HALF) == Half.BOTTOM) { if (blockState.get(StairsBlock.HALF) == Half.BOTTOM) {
return blockState.with(BlockStairs.HALF, Half.TOP); return blockState.with(StairsBlock.HALF, Half.TOP);
} else { } else {
return blockState.with(BlockStairs.HALF, Half.BOTTOM); return blockState.with(StairsBlock.HALF, Half.BOTTOM);
} }
} }
//Slabs //Slabs
if (blockState.getBlock() instanceof BlockSlab) { if (blockState.getBlock() instanceof SlabBlock) {
if (blockState.get(BlockSlab.TYPE) == SlabType.DOUBLE) { if (blockState.get(SlabBlock.TYPE) == SlabType.DOUBLE) {
return blockState; return blockState;
} else if (blockState.get(BlockSlab.TYPE) == SlabType.BOTTOM) { } else if (blockState.get(SlabBlock.TYPE) == SlabType.BOTTOM) {
return blockState.with(BlockSlab.TYPE, SlabType.TOP); return blockState.with(SlabBlock.TYPE, SlabType.TOP);
} else { } else {
return blockState.with(BlockSlab.TYPE, SlabType.BOTTOM); return blockState.with(SlabBlock.TYPE, SlabType.BOTTOM);
} }
} }
//Buttons, endrod, observer, piston //Buttons, endrod, observer, piston
if (blockState.getBlock() instanceof BlockDirectional) { if (blockState.getBlock() instanceof DirectionalBlock) {
if (blockState.get(BlockDirectional.FACING) == EnumFacing.DOWN) { if (blockState.get(DirectionalBlock.FACING) == Direction.DOWN) {
return blockState.with(BlockDirectional.FACING, EnumFacing.UP); return blockState.with(DirectionalBlock.FACING, Direction.UP);
} else if (blockState.get(BlockDirectional.FACING) == EnumFacing.UP) { } else if (blockState.get(DirectionalBlock.FACING) == Direction.UP) {
return blockState.with(BlockDirectional.FACING, EnumFacing.DOWN); return blockState.with(DirectionalBlock.FACING, Direction.DOWN);
} }
} }
//Dispenser, dropper //Dispenser, dropper
if (blockState.getBlock() instanceof BlockDispenser) { if (blockState.getBlock() instanceof DispenserBlock) {
if (blockState.get(BlockDispenser.FACING) == EnumFacing.DOWN) { if (blockState.get(DispenserBlock.FACING) == Direction.DOWN) {
return blockState.with(BlockDispenser.FACING, EnumFacing.UP); return blockState.with(DispenserBlock.FACING, Direction.UP);
} else if (blockState.get(BlockDispenser.FACING) == EnumFacing.UP) { } else if (blockState.get(DispenserBlock.FACING) == Direction.UP) {
return blockState.with(BlockDispenser.FACING, EnumFacing.DOWN); return blockState.with(DispenserBlock.FACING, Direction.DOWN);
} }
} }

View File

@@ -1,7 +1,7 @@
package nl.requios.effortlessbuilding.buildmodifier; package nl.requios.effortlessbuilding.buildmodifier;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.network.PacketDistributor; import net.minecraftforge.fml.network.PacketDistributor;
@@ -13,8 +13,6 @@ import nl.requios.effortlessbuilding.network.ModifierSettingsMessage;
import nl.requios.effortlessbuilding.network.PacketHandler; import nl.requios.effortlessbuilding.network.PacketHandler;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.HashMap;
import java.util.UUID;
@Mod.EventBusSubscriber @Mod.EventBusSubscriber
public class ModifierSettingsManager { public class ModifierSettingsManager {
@@ -22,7 +20,7 @@ public class ModifierSettingsManager {
//Retrieves the buildsettings of a player through the modifierCapability capability //Retrieves the buildsettings of a player through the modifierCapability capability
//Never returns null //Never returns null
@Nonnull @Nonnull
public static ModifierSettings getModifierSettings(EntityPlayer player){ public static ModifierSettings getModifierSettings(PlayerEntity player){
LazyOptional<ModifierCapabilityManager.IModifierCapability> modifierCapability = LazyOptional<ModifierCapabilityManager.IModifierCapability> modifierCapability =
player.getCapability(ModifierCapabilityManager.modifierCapability, null); player.getCapability(ModifierCapabilityManager.modifierCapability, null);
@@ -40,7 +38,7 @@ public class ModifierSettingsManager {
// throw new IllegalArgumentException("Player does not have modifierCapability capability"); // 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) { if (player == null) {
EffortlessBuilding.log("Cannot set buildsettings, player is null"); EffortlessBuilding.log("Cannot set buildsettings, player is null");
return; 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); int maxReach = ReachHelper.getMaxReach(player);
String error = ""; 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) //Makes sure player has modifier settings (if it doesnt it will create it)
getModifierSettings(player); getModifierSettings(player);
@@ -202,7 +200,7 @@ public class ModifierSettingsManager {
if (!player.world.isRemote) { if (!player.world.isRemote) {
//Send to client //Send to client
ModifierSettingsMessage msg = new ModifierSettingsMessage(getModifierSettings(player)); ModifierSettingsMessage msg = new ModifierSettingsMessage(getModifierSettings(player));
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (EntityPlayerMP) player), msg); PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), msg);
} }
} }
} }

View File

@@ -1,10 +1,10 @@
package nl.requios.effortlessbuilding.buildmodifier; package nl.requios.effortlessbuilding.buildmodifier;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing; import net.minecraft.util.Direction;
import net.minecraft.util.EnumHand; import net.minecraft.util.Hand;
import net.minecraft.util.Mirror; import net.minecraft.util.Mirror;
import net.minecraft.util.Rotation; import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos; 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<>(); List<BlockPos> coordinates = new ArrayList<>();
//find radial mirror settings for the player //find radial mirror settings for the player
@@ -77,8 +77,8 @@ public class RadialMirror {
return coordinates; return coordinates;
} }
public static List<IBlockState> findBlockStates(EntityPlayer player, BlockPos startPos, IBlockState blockState, ItemStack itemStack, List<ItemStack> itemStacks) { public static List<BlockState> findBlockStates(PlayerEntity player, BlockPos startPos, BlockState blockState, ItemStack itemStack, List<ItemStack> itemStacks) {
List<IBlockState> blockStates = new ArrayList<>(); List<BlockState> blockStates = new ArrayList<>();
List<BlockPos> coordinates = new ArrayList<>(); //to keep track of duplicates List<BlockPos> coordinates = new ArrayList<>(); //to keep track of duplicates
//find radial mirror settings for the player that placed the block //find radial mirror settings for the player that placed the block
@@ -105,7 +105,7 @@ public class RadialMirror {
bagInventory = ItemRandomizerBag.getBagInventory(itemStack); bagInventory = ItemRandomizerBag.getBagInventory(itemStack);
} }
IBlockState newBlockState; BlockState newBlockState;
for (int i = 1; i < r.slices; i++) { for (int i = 1; i < r.slices; i++) {
newBlockState = blockState; newBlockState = blockState;
double curAngle = sliceAngle * i; double curAngle = sliceAngle * i;
@@ -124,7 +124,7 @@ public class RadialMirror {
if (bagInventory != null) { if (bagInventory != null) {
itemStack = ItemRandomizerBag.pickRandomStack(bagInventory); itemStack = ItemRandomizerBag.pickRandomStack(bagInventory);
newBlockState = BuildModifiers 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); newBlockState = rotateOriginalBlockState(startAngleToCenter, newBlockState);
} }
@@ -139,8 +139,8 @@ public class RadialMirror {
return blockStates; return blockStates;
} }
private static IBlockState rotateOriginalBlockState(double startAngleToCenter, IBlockState blockState) { private static BlockState rotateOriginalBlockState(double startAngleToCenter, BlockState blockState) {
IBlockState newBlockState = blockState; BlockState newBlockState = blockState;
if (startAngleToCenter < -0.751 * Math.PI || startAngleToCenter > 0.749 * Math.PI) { if (startAngleToCenter < -0.751 * Math.PI || startAngleToCenter > 0.749 * Math.PI) {
newBlockState = blockState.rotate(Rotation.CLOCKWISE_180); newBlockState = blockState.rotate(Rotation.CLOCKWISE_180);
@@ -153,8 +153,8 @@ public class RadialMirror {
return newBlockState; return newBlockState;
} }
private static IBlockState rotateBlockState(Vec3d relVec, IBlockState blockState, boolean alternate) { private static BlockState rotateBlockState(Vec3d relVec, BlockState blockState, boolean alternate) {
IBlockState newBlockState; BlockState newBlockState;
double angleToCenter = MathHelper.atan2(relVec.x, relVec.z); //between -PI and PI double angleToCenter = MathHelper.atan2(relVec.x, relVec.z); //between -PI and PI
if (angleToCenter < -0.751 * Math.PI || angleToCenter > 0.749 * Math.PI) { if (angleToCenter < -0.751 * Math.PI || angleToCenter > 0.749 * Math.PI) {

View File

@@ -1,15 +1,17 @@
package nl.requios.effortlessbuilding.buildmodifier; package nl.requios.effortlessbuilding.buildmodifier;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.block.Blocks;
import net.minecraft.init.Blocks; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack; 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.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.world.storage.loot.LootContext;
import nl.requios.effortlessbuilding.BuildConfig; import nl.requios.effortlessbuilding.BuildConfig;
import nl.requios.effortlessbuilding.EffortlessBuilding; import nl.requios.effortlessbuilding.EffortlessBuilding;
import nl.requios.effortlessbuilding.helper.FixedStack; import nl.requios.effortlessbuilding.helper.FixedStack;
@@ -29,7 +31,7 @@ public class UndoRedo {
private static Map<UUID, FixedStack<BlockSet>> redoStacksServer = new HashMap<>(); private static Map<UUID, FixedStack<BlockSet>> redoStacksServer = new HashMap<>();
//add to undo stack //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; Map<UUID, FixedStack<BlockSet>> undoStacks = player.world.isRemote ? undoStacksClient : undoStacksServer;
//Assert coordinates is as long as previous and new blockstate lists //Assert coordinates is as long as previous and new blockstate lists
@@ -56,7 +58,7 @@ public class UndoRedo {
undoStacks.get(player.getUniqueID()).push(blockSet); 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; Map<UUID, FixedStack<BlockSet>> redoStacks = player.world.isRemote ? redoStacksClient : redoStacksServer;
//(No asserts necessary, it's private) //(No asserts necessary, it's private)
@@ -69,7 +71,7 @@ public class UndoRedo {
redoStacks.get(player.getUniqueID()).push(blockSet); 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; Map<UUID, FixedStack<BlockSet>> undoStacks = player.world.isRemote ? undoStacksClient : undoStacksServer;
if (!undoStacks.containsKey(player.getUniqueID())) return false; if (!undoStacks.containsKey(player.getUniqueID())) return false;
@@ -80,8 +82,8 @@ public class UndoRedo {
BlockSet blockSet = undoStack.pop(); BlockSet blockSet = undoStack.pop();
List<BlockPos> coordinates = blockSet.getCoordinates(); List<BlockPos> coordinates = blockSet.getCoordinates();
List<IBlockState> previousBlockStates = blockSet.getPreviousBlockStates(); List<BlockState> previousBlockStates = blockSet.getPreviousBlockStates();
List<IBlockState> newBlockStates = blockSet.getNewBlockStates(); List<BlockState> newBlockStates = blockSet.getNewBlockStates();
Vec3d hitVec = blockSet.getHitVec(); Vec3d hitVec = blockSet.getHitVec();
//Find up to date itemstacks in player inventory //Find up to date itemstacks in player inventory
@@ -98,17 +100,17 @@ public class UndoRedo {
if (previousBlockStates.get(i).equals(newBlockStates.get(i))) continue; if (previousBlockStates.get(i).equals(newBlockStates.get(i))) continue;
//get blockstate from itemstack //get blockstate from itemstack
IBlockState previousBlockState = Blocks.AIR.getDefaultState(); BlockState previousBlockState = Blocks.AIR.getDefaultState();
if (itemStack.getItem() instanceof ItemBlock) { if (itemStack.getItem() instanceof BlockItem) {
previousBlockState = previousBlockStates.get(i);//((ItemBlock) itemStack.getItem()).getBlock().getDefaultState(); previousBlockState = previousBlockStates.get(i);//((ItemBlock) itemStack.getItem()).getBlock().getDefaultState();
} }
if (player.world.isBlockLoaded(coordinate, true)) { if (player.world.isBlockPresent(coordinate)) {
//check itemstack empty //check itemstack empty
if (itemStack.isEmpty()) { if (itemStack.isEmpty()) {
itemStack = findItemStackInInventory(player, previousBlockStates.get(i)); itemStack = findItemStackInInventory(player, previousBlockStates.get(i));
//get blockstate from new itemstack //get blockstate from new itemstack
if (!itemStack.isEmpty() && itemStack.getItem() instanceof ItemBlock) { if (!itemStack.isEmpty() && itemStack.getItem() instanceof BlockItem) {
previousBlockState = previousBlockStates.get(i);//((ItemBlock) itemStack.getItem()).getBlock().getDefaultState(); previousBlockState = previousBlockStates.get(i);//((ItemBlock) itemStack.getItem()).getBlock().getDefaultState();
} else { } else {
previousBlockState = Blocks.AIR.getDefaultState(); previousBlockState = Blocks.AIR.getDefaultState();
@@ -116,7 +118,7 @@ public class UndoRedo {
} }
if (itemStack.isEmpty()) SurvivalHelper.breakBlock(player.world, player, coordinate, true); if (itemStack.isEmpty()) SurvivalHelper.breakBlock(player.world, player, coordinate, true);
//if previousBlockState is air, placeBlock will set it to air //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 +129,7 @@ public class UndoRedo {
return true; return true;
} }
public static boolean redo(EntityPlayer player) { public static boolean redo(PlayerEntity player) {
Map<UUID, FixedStack<BlockSet>> redoStacks = player.world.isRemote ? redoStacksClient : redoStacksServer; Map<UUID, FixedStack<BlockSet>> redoStacks = player.world.isRemote ? redoStacksClient : redoStacksServer;
if (!redoStacks.containsKey(player.getUniqueID())) return false; if (!redoStacks.containsKey(player.getUniqueID())) return false;
@@ -138,8 +140,8 @@ public class UndoRedo {
BlockSet blockSet = redoStack.pop(); BlockSet blockSet = redoStack.pop();
List<BlockPos> coordinates = blockSet.getCoordinates(); List<BlockPos> coordinates = blockSet.getCoordinates();
List<IBlockState> previousBlockStates = blockSet.getPreviousBlockStates(); List<BlockState> previousBlockStates = blockSet.getPreviousBlockStates();
List<IBlockState> newBlockStates = blockSet.getNewBlockStates(); List<BlockState> newBlockStates = blockSet.getNewBlockStates();
Vec3d hitVec = blockSet.getHitVec(); Vec3d hitVec = blockSet.getHitVec();
//Find up to date itemstacks in player inventory //Find up to date itemstacks in player inventory
@@ -156,24 +158,24 @@ public class UndoRedo {
if (previousBlockStates.get(i).equals(newBlockStates.get(i))) continue; if (previousBlockStates.get(i).equals(newBlockStates.get(i))) continue;
//get blockstate from itemstack //get blockstate from itemstack
IBlockState newBlockState = Blocks.AIR.getDefaultState(); BlockState newBlockState = Blocks.AIR.getDefaultState();
if (itemStack.getItem() instanceof ItemBlock) { if (itemStack.getItem() instanceof BlockItem) {
newBlockState = newBlockStates.get(i);//((ItemBlock) itemStack.getItem()).getBlock().getDefaultState(); newBlockState = newBlockStates.get(i);//((ItemBlock) itemStack.getItem()).getBlock().getDefaultState();
} }
if (player.world.isBlockLoaded(coordinate, true)) { if (player.world.isBlockPresent(coordinate)) {
//check itemstack empty //check itemstack empty
if (itemStack.isEmpty()) { if (itemStack.isEmpty()) {
itemStack = findItemStackInInventory(player, newBlockStates.get(i)); itemStack = findItemStackInInventory(player, newBlockStates.get(i));
//get blockstate from new itemstack //get blockstate from new itemstack
if (!itemStack.isEmpty() && itemStack.getItem() instanceof ItemBlock) { if (!itemStack.isEmpty() && itemStack.getItem() instanceof BlockItem) {
newBlockState = newBlockStates.get(i);//((ItemBlock) itemStack.getItem()).getBlock().getDefaultState(); newBlockState = newBlockStates.get(i);//((ItemBlock) itemStack.getItem()).getBlock().getDefaultState();
} else { } else {
newBlockState = Blocks.AIR.getDefaultState(); newBlockState = Blocks.AIR.getDefaultState();
} }
} }
if (itemStack.isEmpty()) SurvivalHelper.breakBlock(player.world, player, coordinate, true); 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 +186,7 @@ public class UndoRedo {
return true; 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>> undoStacks = player.world.isRemote ? undoStacksClient : undoStacksServer;
Map<UUID, FixedStack<BlockSet>> redoStacks = player.world.isRemote ? redoStacksClient : redoStacksServer; Map<UUID, FixedStack<BlockSet>> redoStacks = player.world.isRemote ? redoStacksClient : redoStacksServer;
if (undoStacks.containsKey(player.getUniqueID())) { if (undoStacks.containsKey(player.getUniqueID())) {
@@ -195,15 +197,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()); List<ItemStack> itemStacks = new ArrayList<>(blockStates.size());
for (IBlockState blockState : blockStates) { for (BlockState blockState : blockStates) {
itemStacks.add(findItemStackInInventory(player, blockState)); itemStacks.add(findItemStackInInventory(player, blockState));
} }
return itemStacks; return itemStacks;
} }
private static ItemStack findItemStackInInventory(EntityPlayer player, IBlockState blockState) { private static ItemStack findItemStackInInventory(PlayerEntity player, BlockState blockState) {
ItemStack itemStack = ItemStack.EMPTY; ItemStack itemStack = ItemStack.EMPTY;
//First try previousBlockStates //First try previousBlockStates
@@ -213,10 +215,12 @@ public class UndoRedo {
//then anything it drops //then anything it drops
if (itemStack.isEmpty()) { if (itemStack.isEmpty()) {
Item itemDropped = blockState.getBlock().getItemDropped(blockState, player.world, BlockPos.ORIGIN, 10).asItem(); List<ItemStack> itemsDropped = blockState.getDrops(new LootContext.Builder((ServerWorld) player.world));
if (itemDropped instanceof ItemBlock) { for (ItemStack itemStackDropped : itemsDropped) {
Block block = ((ItemBlock) itemDropped).getBlock(); if (itemStackDropped.getItem() instanceof BlockItem) {
itemStack = InventoryHelper.findItemStackInInventory(player, block); Block block = ((BlockItem) itemStackDropped.getItem()).getBlock();
itemStack = InventoryHelper.findItemStackInInventory(player, block);
}
} }
} }

View File

@@ -1,9 +1,8 @@
package nl.requios.effortlessbuilding.capability; package nl.requios.effortlessbuilding.capability;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.EnumFacing; import net.minecraft.util.Direction;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityInject;
import net.minecraftforge.common.capabilities.ICapabilitySerializable; import net.minecraftforge.common.capabilities.ICapabilitySerializable;
import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.CapabilityItemHandler;
@@ -14,22 +13,22 @@ import nl.requios.effortlessbuilding.item.ItemRandomizerBag;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
public class ItemHandlerCapabilityProvider implements ICapabilitySerializable<NBTTagCompound> { public class ItemHandlerCapabilityProvider implements ICapabilitySerializable<CompoundNBT> {
IItemHandler itemHandler = new ItemStackHandler(ItemRandomizerBag.INV_SIZE); IItemHandler itemHandler = new ItemStackHandler(ItemRandomizerBag.INV_SIZE);
@Nonnull @Nonnull
@Override @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)); return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.orEmpty(cap, LazyOptional.of(() -> itemHandler));
} }
@Override @Override
public NBTTagCompound serializeNBT() { public CompoundNBT serializeNBT() {
return ((ItemStackHandler) itemHandler).serializeNBT(); return ((ItemStackHandler) itemHandler).serializeNBT();
} }
@Override @Override
public void deserializeNBT(NBTTagCompound nbt) { public void deserializeNBT(CompoundNBT nbt) {
((ItemStackHandler) itemHandler).deserializeNBT(nbt); ((ItemStackHandler) itemHandler).deserializeNBT(nbt);
} }
} }

View File

@@ -1,8 +1,8 @@
package nl.requios.effortlessbuilding.capability; package nl.requios.effortlessbuilding.capability;
import net.minecraft.nbt.INBTBase; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.INBT;
import net.minecraft.util.EnumFacing; import net.minecraft.util.Direction;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityInject; import net.minecraftforge.common.capabilities.CapabilityInject;
import net.minecraftforge.common.capabilities.ICapabilitySerializable; import net.minecraftforge.common.capabilities.ICapabilitySerializable;
@@ -45,12 +45,12 @@ public class ModeCapabilityManager {
public static class Storage implements Capability.IStorage<IModeCapability> { public static class Storage implements Capability.IStorage<IModeCapability> {
@Override @Override
public INBTBase writeNBT(Capability<IModeCapability> capability, IModeCapability instance, EnumFacing side) { public INBT writeNBT(Capability<IModeCapability> capability, IModeCapability instance, Direction side) {
NBTTagCompound compound = new NBTTagCompound(); CompoundNBT compound = new CompoundNBT();
ModeSettings modeSettings = instance.getModeData(); ModeSettings modeSettings = instance.getModeData();
if (modeSettings == null) modeSettings = new ModeSettings(); if (modeSettings == null) modeSettings = new ModeSettings();
//compound.setInteger("buildMode", modeSettings.getBuildMode().ordinal()); //compound.putInteger("buildMode", modeSettings.getBuildMode().ordinal());
//TODO add mode settings //TODO add mode settings
@@ -58,8 +58,8 @@ public class ModeCapabilityManager {
} }
@Override @Override
public void readNBT(Capability<IModeCapability> capability, IModeCapability instance, EnumFacing side, INBTBase nbt) { public void readNBT(Capability<IModeCapability> capability, IModeCapability instance, Direction side, INBT nbt) {
NBTTagCompound compound = (NBTTagCompound) nbt; CompoundNBT compound = (CompoundNBT) nbt;
//BuildModes.BuildModeEnum buildMode = BuildModes.BuildModeEnum.values()[compound.getInteger("buildMode")]; //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(); IModeCapability inst = modeCapability.getDefaultInstance();
@Nonnull @Nonnull
@Override @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)); return modeCapability.orEmpty(cap, LazyOptional.of(() -> inst));
} }
@Override @Override
public INBTBase serializeNBT() { public INBT serializeNBT() {
return modeCapability.getStorage().writeNBT(modeCapability, inst, null); return modeCapability.getStorage().writeNBT(modeCapability, inst, null);
} }
@Override @Override
public void deserializeNBT(INBTBase nbt) { public void deserializeNBT(INBT nbt) {
modeCapability.getStorage().readNBT(modeCapability, inst, null, nbt); modeCapability.getStorage().readNBT(modeCapability, inst, null, nbt);
} }

View File

@@ -1,8 +1,8 @@
package nl.requios.effortlessbuilding.capability; package nl.requios.effortlessbuilding.capability;
import net.minecraft.nbt.INBTBase; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.INBT;
import net.minecraft.util.EnumFacing; import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraftforge.common.capabilities.Capability; 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.event.entity.player.PlayerEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import nl.requios.effortlessbuilding.EffortlessBuilding;
import nl.requios.effortlessbuilding.buildmodifier.Array; import nl.requios.effortlessbuilding.buildmodifier.Array;
import nl.requios.effortlessbuilding.buildmodifier.Mirror; import nl.requios.effortlessbuilding.buildmodifier.Mirror;
import nl.requios.effortlessbuilding.buildmodifier.RadialMirror; import nl.requios.effortlessbuilding.buildmodifier.RadialMirror;
@@ -20,8 +19,6 @@ import nl.requios.effortlessbuilding.buildmodifier.RadialMirror;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.concurrent.Callable;
import static nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager.*; import static nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager.*;
@Mod.EventBusSubscriber @Mod.EventBusSubscriber
@@ -52,57 +49,57 @@ public class ModifierCapabilityManager {
public static class Storage implements Capability.IStorage<IModifierCapability> { public static class Storage implements Capability.IStorage<IModifierCapability> {
@Override @Override
public INBTBase writeNBT(Capability<IModifierCapability> capability, IModifierCapability instance, EnumFacing side) { public INBT writeNBT(Capability<IModifierCapability> capability, IModifierCapability instance, Direction side) {
NBTTagCompound compound = new NBTTagCompound(); CompoundNBT compound = new CompoundNBT();
ModifierSettings modifierSettings = instance.getModifierData(); ModifierSettings modifierSettings = instance.getModifierData();
if (modifierSettings == null) modifierSettings = new ModifierSettings(); if (modifierSettings == null) modifierSettings = new ModifierSettings();
//MIRROR //MIRROR
Mirror.MirrorSettings m = modifierSettings.getMirrorSettings(); Mirror.MirrorSettings m = modifierSettings.getMirrorSettings();
if (m == null) m = new Mirror.MirrorSettings(); if (m == null) m = new Mirror.MirrorSettings();
compound.setBoolean("mirrorEnabled", m.enabled); compound.putBoolean("mirrorEnabled", m.enabled);
compound.setDouble("mirrorPosX", m.position.x); compound.putDouble("mirrorPosX", m.position.x);
compound.setDouble("mirrorPosY", m.position.y); compound.putDouble("mirrorPosY", m.position.y);
compound.setDouble("mirrorPosZ", m.position.z); compound.putDouble("mirrorPosZ", m.position.z);
compound.setBoolean("mirrorX", m.mirrorX); compound.putBoolean("mirrorX", m.mirrorX);
compound.setBoolean("mirrorY", m.mirrorY); compound.putBoolean("mirrorY", m.mirrorY);
compound.setBoolean("mirrorZ", m.mirrorZ); compound.putBoolean("mirrorZ", m.mirrorZ);
compound.setInt("mirrorRadius", m.radius); compound.putInt("mirrorRadius", m.radius);
compound.setBoolean("mirrorDrawLines", m.drawLines); compound.putBoolean("mirrorDrawLines", m.drawLines);
compound.setBoolean("mirrorDrawPlanes", m.drawPlanes); compound.putBoolean("mirrorDrawPlanes", m.drawPlanes);
//ARRAY //ARRAY
Array.ArraySettings a = modifierSettings.getArraySettings(); Array.ArraySettings a = modifierSettings.getArraySettings();
if (a == null) a = new Array.ArraySettings(); if (a == null) a = new Array.ArraySettings();
compound.setBoolean("arrayEnabled", a.enabled); compound.putBoolean("arrayEnabled", a.enabled);
compound.setInt("arrayOffsetX", a.offset.getX()); compound.putInt("arrayOffsetX", a.offset.getX());
compound.setInt("arrayOffsetY", a.offset.getY()); compound.putInt("arrayOffsetY", a.offset.getY());
compound.setInt("arrayOffsetZ", a.offset.getZ()); compound.putInt("arrayOffsetZ", a.offset.getZ());
compound.setInt("arrayCount", a.count); 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 //RADIAL MIRROR
RadialMirror.RadialMirrorSettings r = modifierSettings.getRadialMirrorSettings(); RadialMirror.RadialMirrorSettings r = modifierSettings.getRadialMirrorSettings();
if (r == null) r = new RadialMirror.RadialMirrorSettings(); if (r == null) r = new RadialMirror.RadialMirrorSettings();
compound.setBoolean("radialMirrorEnabled", r.enabled); compound.putBoolean("radialMirrorEnabled", r.enabled);
compound.setDouble("radialMirrorPosX", r.position.x); compound.putDouble("radialMirrorPosX", r.position.x);
compound.setDouble("radialMirrorPosY", r.position.y); compound.putDouble("radialMirrorPosY", r.position.y);
compound.setDouble("radialMirrorPosZ", r.position.z); compound.putDouble("radialMirrorPosZ", r.position.z);
compound.setInt("radialMirrorSlices", r.slices); compound.putInt("radialMirrorSlices", r.slices);
compound.setBoolean("radialMirrorAlternate", r.alternate); compound.putBoolean("radialMirrorAlternate", r.alternate);
compound.setInt("radialMirrorRadius", r.radius); compound.putInt("radialMirrorRadius", r.radius);
compound.setBoolean("radialMirrorDrawLines", r.drawLines); compound.putBoolean("radialMirrorDrawLines", r.drawLines);
compound.setBoolean("radialMirrorDrawPlanes", r.drawPlanes); compound.putBoolean("radialMirrorDrawPlanes", r.drawPlanes);
return compound; return compound;
} }
@Override @Override
public void readNBT(Capability<IModifierCapability> capability, IModifierCapability instance, EnumFacing side, INBTBase nbt) { public void readNBT(Capability<IModifierCapability> capability, IModifierCapability instance, Direction side, INBT nbt) {
NBTTagCompound compound = (NBTTagCompound) nbt; CompoundNBT compound = (CompoundNBT) nbt;
//MIRROR //MIRROR
boolean mirrorEnabled = compound.getBoolean("mirrorEnabled"); 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(); IModifierCapability inst = modifierCapability.getDefaultInstance();
@Nonnull @Nonnull
@Override @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)); return modifierCapability.orEmpty(cap, LazyOptional.of(() -> inst));
} }
@Override @Override
public INBTBase serializeNBT() { public INBT serializeNBT() {
return modifierCapability.getStorage().writeNBT(modifierCapability, inst, null); return modifierCapability.getStorage().writeNBT(modifierCapability, inst, null);
} }
@Override @Override
public void deserializeNBT(INBTBase nbt) { public void deserializeNBT(INBT nbt) {
modifierCapability.getStorage().readNBT(modifierCapability, inst, null, nbt); modifierCapability.getStorage().readNBT(modifierCapability, inst, null, nbt);
} }

View File

@@ -4,14 +4,13 @@ import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.IntegerArgumentType; import com.mojang.brigadier.arguments.IntegerArgumentType;
import net.minecraft.command.CommandSource; import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands; import net.minecraft.command.Commands;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.fml.network.PacketDistributor; import net.minecraftforge.fml.network.PacketDistributor;
import nl.requios.effortlessbuilding.EffortlessBuilding; import nl.requios.effortlessbuilding.EffortlessBuilding;
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager; import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
import nl.requios.effortlessbuilding.network.ModifierSettingsMessage; import nl.requios.effortlessbuilding.network.ModifierSettingsMessage;
import nl.requios.effortlessbuilding.network.PacketHandler; import nl.requios.effortlessbuilding.network.PacketHandler;
import nl.requios.effortlessbuilding.network.RequestLookAtMessage;
public class CommandReach { 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); ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
modifierSettings.setReachUpgrade(level); modifierSettings.setReachUpgrade(level);
ModifierSettingsManager.setModifierSettings(player, modifierSettings); ModifierSettingsManager.setModifierSettings(player, modifierSettings);
//Send to client //Send to client
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> player), new ModifierSettingsMessage(modifierSettings)); 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; return 1;
} }
private static int getReachLevel(EntityPlayerMP player){ private static int getReachLevel(ServerPlayerEntity player){
int reachUpgrade = ModifierSettingsManager.getModifierSettings(player).getReachUpgrade(); int reachUpgrade = ModifierSettingsManager.getModifierSettings(player).getReachUpgrade();
EffortlessBuilding.log(player, "Current reach: level "+reachUpgrade); EffortlessBuilding.log(player, "Current reach: level "+reachUpgrade);

View File

@@ -1,11 +1,10 @@
package nl.requios.effortlessbuilding.compatibility; package nl.requios.effortlessbuilding.compatibility;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHand;
import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
@@ -39,7 +38,7 @@ public class CompatHelper {
// /dank/null, or plain old blocks. // /dank/null, or plain old blocks.
public static boolean isItemBlockProxy(ItemStack stack) { public static boolean isItemBlockProxy(ItemStack stack) {
Item item = stack.getItem(); Item item = stack.getItem();
if (item instanceof ItemBlock) if (item instanceof BlockItem)
return true; return true;
if ((item instanceof ItemRandomizerBag)) if ((item instanceof ItemRandomizerBag))
return true; return true;
@@ -54,13 +53,13 @@ public class CompatHelper {
public static ItemStack getItemBlockFromStack(ItemStack proxy) { public static ItemStack getItemBlockFromStack(ItemStack proxy) {
Item proxyItem = proxy.getItem(); Item proxyItem = proxy.getItem();
if (proxyItem instanceof ItemBlock) if (proxyItem instanceof BlockItem)
return proxy; return proxy;
//Randomizer Bag //Randomizer Bag
if (proxyItem instanceof ItemRandomizerBag) { if (proxyItem instanceof ItemRandomizerBag) {
ItemStack itemStack = proxy; ItemStack itemStack = proxy;
while (!(itemStack.getItem() instanceof ItemBlock || itemStack.isEmpty())) { while (!(itemStack.getItem() instanceof BlockItem || itemStack.isEmpty())) {
if (itemStack.getItem() instanceof ItemRandomizerBag) if (itemStack.getItem() instanceof ItemRandomizerBag)
itemStack = ItemRandomizerBag.pickRandomStack(ItemRandomizerBag.getBagInventory(itemStack)); itemStack = ItemRandomizerBag.pickRandomStack(ItemRandomizerBag.getBagInventory(itemStack));
} }
@@ -79,11 +78,11 @@ public class CompatHelper {
return ItemStack.EMPTY; 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; if (state == null) return ItemStack.EMPTY;
Item blockItem = Item.getItemFromBlock(state.getBlock()); Item blockItem = Item.getItemFromBlock(state.getBlock());
if (stack.getItem() instanceof ItemBlock) if (stack.getItem() instanceof BlockItem)
return stack; return stack;
else if (stack.getItem() instanceof ItemRandomizerBag) { else if (stack.getItem() instanceof ItemRandomizerBag) {
IItemHandler bagInventory = ItemRandomizerBag.getBagInventory(stack); IItemHandler bagInventory = ItemRandomizerBag.getBagInventory(stack);
@@ -100,7 +99,7 @@ public class CompatHelper {
// Handle IItemHandler slot stacks not being modifiable. We must call IItemHandler#extractItem, // Handle IItemHandler slot stacks not being modifiable. We must call IItemHandler#extractItem,
// because the ItemStack returned by IItemHandler#getStackInSlot isn't modifiable. // 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 //TODO 1.13 compatibility, offhand support
//Hacky way to get the origstack, because given origStack is itemblock stack and never proxy //Hacky way to get the origstack, because given origStack is itemblock stack and never proxy
// origStack = player.getHeldItem(EnumHand.MAIN_HAND); // origStack = player.getHeldItem(EnumHand.MAIN_HAND);
@@ -123,7 +122,7 @@ public class CompatHelper {
for (int i = 0; i < handler.getSlots(); i++) { for (int i = 0; i < handler.getSlots(); i++) {
ItemStack ref = handler.getStackInSlot(i); ItemStack ref = handler.getStackInSlot(i);
if (ref.getItem() instanceof ItemBlock) if (ref.getItem() instanceof BlockItem)
if (ref.getItem() == blockItem) if (ref.getItem() == blockItem)
return i; return i;
} }

View File

@@ -1,12 +1,12 @@
package nl.requios.effortlessbuilding.gui; package nl.requios.effortlessbuilding.gui;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.ClickType; import net.minecraft.inventory.container.ClickType;
import net.minecraft.inventory.Container; import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.container.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHand; import net.minecraft.util.Hand;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.SlotItemHandler; import net.minecraftforge.items.SlotItemHandler;
import nl.requios.effortlessbuilding.item.ItemRandomizerBag; import nl.requios.effortlessbuilding.item.ItemRandomizerBag;
@@ -19,7 +19,7 @@ public class RandomizerBagContainer extends Container {
private static final int INV_START = ItemRandomizerBag.INV_SIZE, INV_END = INV_START + 26, private static final int INV_START = ItemRandomizerBag.INV_SIZE, INV_END = INV_START + 26,
HOTBAR_START = INV_END + 1, HOTBAR_END = HOTBAR_START + 8; HOTBAR_START = INV_END + 1, HOTBAR_END = HOTBAR_START + 8;
public RandomizerBagContainer(InventoryPlayer parInventoryPlayer, IItemHandler parIInventory) { public RandomizerBagContainer(PlayerInventory parInventoryPlayer, IItemHandler parIInventory) {
bagInventory = parIInventory; bagInventory = parIInventory;
sizeInventory = bagInventory.getSlots(); sizeInventory = bagInventory.getSlots();
for (int i = 0; i < sizeInventory; ++i) { for (int i = 0; i < sizeInventory; ++i) {
@@ -41,7 +41,7 @@ public class RandomizerBagContainer extends Container {
} }
@Override @Override
public boolean canInteractWith(EntityPlayer playerIn) { public boolean canInteractWith(PlayerEntity playerIn) {
return true; return true;
} }
@@ -54,7 +54,7 @@ public class RandomizerBagContainer extends Container {
} }
@Override @Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int slotIndex) { public ItemStack transferStackInSlot(PlayerEntity playerIn, int slotIndex) {
ItemStack itemstack = ItemStack.EMPTY; ItemStack itemstack = ItemStack.EMPTY;
Slot slot = this.inventorySlots.get(slotIndex); Slot slot = this.inventorySlots.get(slotIndex);
@@ -107,9 +107,9 @@ public class RandomizerBagContainer extends Container {
* be able to save properly * be able to save properly
*/ */
@Override @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: // 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 ItemStack.EMPTY;
} }
return super.slotClick(slot, dragType, clickTypeIn, player); return super.slotClick(slot, dragType, clickTypeIn, player);
@@ -119,7 +119,7 @@ public class RandomizerBagContainer extends Container {
* Callback for when the crafting gui is closed. * Callback for when the crafting gui is closed.
*/ */
@Override @Override
public void onContainerClosed(EntityPlayer player) public void onContainerClosed(PlayerEntity player)
{ {
super.onContainerClosed(player); super.onContainerClosed(player);
if(!player.world.isRemote) if(!player.world.isRemote)

View File

@@ -1,8 +1,9 @@
package nl.requios.effortlessbuilding.gui; package nl.requios.effortlessbuilding.gui;
import net.minecraft.client.gui.inventory.GuiContainer; import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
@@ -10,13 +11,13 @@ import net.minecraftforge.items.IItemHandler;
import nl.requios.effortlessbuilding.EffortlessBuilding; import nl.requios.effortlessbuilding.EffortlessBuilding;
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public class RandomizerBagGuiContainer extends GuiContainer { public class RandomizerBagGuiContainer extends ContainerScreen {
private static final ResourceLocation guiTextures = private static final ResourceLocation guiTextures =
new ResourceLocation(EffortlessBuilding.MODID, "textures/gui/container/randomizerbag.png"); new ResourceLocation(EffortlessBuilding.MODID, "textures/gui/container/randomizerbag.png");
private final InventoryPlayer inventoryPlayer; private final PlayerInventory inventoryPlayer;
private final IItemHandler inventoryBag; private final IItemHandler inventoryBag;
public RandomizerBagGuiContainer(InventoryPlayer inventoryPlayer, IItemHandler inventoryBag) { public RandomizerBagGuiContainer(PlayerInventory inventoryPlayer, IItemHandler inventoryBag) {
super(new RandomizerBagContainer(inventoryPlayer, inventoryBag)); super(new RandomizerBagContainer(inventoryPlayer, inventoryBag));
this.inventoryPlayer = inventoryPlayer; this.inventoryPlayer = inventoryPlayer;
this.inventoryBag = inventoryBag; this.inventoryBag = inventoryBag;
@@ -34,14 +35,14 @@ public class RandomizerBagGuiContainer extends GuiContainer {
@Override @Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
String s = "Randomizer Bag"; String s = "Randomizer Bag";
fontRenderer.drawString(s, 8, 6, 0x404040); font.drawString(s, 8, 6, 0x404040);
fontRenderer.drawString(inventoryPlayer.getDisplayName().getUnformattedComponentText(), 8, ySize - 96 + 2, 0x404040); font.drawString(inventoryPlayer.getDisplayName().getUnformattedComponentText(), 8, ySize - 96 + 2, 0x404040);
} }
@Override @Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
GlStateManager.color3f(1.0F, 1.0F, 1.0F); GlStateManager.color3f(1.0F, 1.0F, 1.0F);
mc.getTextureManager().bindTexture(guiTextures); minecraft.getTextureManager().bindTexture(guiTextures);
int marginHorizontal = (width - xSize) / 2; int marginHorizontal = (width - xSize) / 2;
int marginVertical = (height - ySize) / 2; int marginVertical = (height - ySize) / 2;
drawTexturedModalRect(marginHorizontal, marginVertical, 0, 0, xSize, ySize); drawTexturedModalRect(marginHorizontal, marginVertical, 0, 0, xSize, ySize);

View File

@@ -1,30 +1,25 @@
package nl.requios.effortlessbuilding.gui; package nl.requios.effortlessbuilding.gui;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.screen.Screen;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.Container; import net.minecraft.inventory.container.Container;
import net.minecraft.util.EnumHand; import net.minecraft.util.Hand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.StringTextComponent;
import net.minecraft.world.IInteractionObject; import net.minecraft.world.IInteractionObject;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; 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.fml.network.FMLPlayMessages;
import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import nl.requios.effortlessbuilding.EffortlessBuilding; import nl.requios.effortlessbuilding.EffortlessBuilding;
import nl.requios.effortlessbuilding.capability.ItemHandlerCapabilityProvider;
import nl.requios.effortlessbuilding.item.ItemRandomizerBag; import nl.requios.effortlessbuilding.item.ItemRandomizerBag;
import javax.annotation.Nullable; import javax.annotation.Nullable;
TODO 1.14 GUI
public class RandomizerBagGuiHandler implements /*IGuiHandler, */IInteractionObject { public class RandomizerBagGuiHandler implements /*IGuiHandler, */IInteractionObject {
// @Nullable // @Nullable
// @Override // @Override
@@ -60,11 +55,11 @@ public class RandomizerBagGuiHandler implements /*IGuiHandler, */IInteractionObj
// } // }
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public static GuiScreen openGui(FMLPlayMessages.OpenContainer openContainer) { public static Screen openGui(FMLPlayMessages.OpenContainer openContainer) {
if (openContainer.getId().equals(EffortlessBuilding.RANDOMIZER_BAG_GUI)) { if (openContainer.getId().equals(EffortlessBuilding.RANDOMIZER_BAG_GUI)) {
EntityPlayerSP player = Minecraft.getInstance().player; ClientPlayerEntity player = Minecraft.getInstance().player;
if (player.getHeldItem(EnumHand.MAIN_HAND).getItem() instanceof ItemRandomizerBag) { if (player.getHeldItem(Hand.MAIN_HAND).getItem() instanceof ItemRandomizerBag) {
IItemHandler itemHandler = player.getHeldItem(EnumHand.MAIN_HAND).getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElse(null); IItemHandler itemHandler = player.getHeldItem(Hand.MAIN_HAND).getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElse(null);
if (itemHandler != null) { if (itemHandler != null) {
return new RandomizerBagGuiContainer(player.inventory, itemHandler); return new RandomizerBagGuiContainer(player.inventory, itemHandler);
} }
@@ -74,9 +69,9 @@ public class RandomizerBagGuiHandler implements /*IGuiHandler, */IInteractionObj
} }
@Override @Override
public Container createContainer(InventoryPlayer inventory, EntityPlayer player) { public Container createContainer(PlayerInventory inventory, PlayerEntity player) {
if (player.getHeldItem(EnumHand.MAIN_HAND).getItem() instanceof ItemRandomizerBag) { if (player.getHeldItem(Hand.MAIN_HAND).getItem() instanceof ItemRandomizerBag) {
IItemHandler itemHandler = player.getHeldItem(EnumHand.MAIN_HAND).getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElse(null); IItemHandler itemHandler = player.getHeldItem(Hand.MAIN_HAND).getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElse(null);
if (itemHandler != null) { if (itemHandler != null) {
return new RandomizerBagContainer(inventory, itemHandler); return new RandomizerBagContainer(inventory, itemHandler);
} }
@@ -91,7 +86,7 @@ public class RandomizerBagGuiHandler implements /*IGuiHandler, */IInteractionObj
@Override @Override
public ITextComponent getName() { public ITextComponent getName() {
return new TextComponentString("Randomizer Bag"); return new StringTextComponent("Randomizer Bag");
} }
@Override @Override
@@ -101,7 +96,7 @@ public class RandomizerBagGuiHandler implements /*IGuiHandler, */IInteractionObj
@Override @Override
public ITextComponent getDisplayName() { public ITextComponent getDisplayName() {
return new TextComponentString("Randomizer Bag"); return new StringTextComponent("Randomizer Bag");
} }
@Nullable @Nullable

View File

@@ -3,11 +3,12 @@ package nl.requios.effortlessbuilding.gui.buildmode;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.concurrent.TimeUnit; 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.resources.I18n;
import net.minecraft.client.settings.KeyBinding; import net.minecraft.util.Direction;
import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TextFormatting;
import nl.requios.effortlessbuilding.EffortlessBuilding; import nl.requios.effortlessbuilding.EffortlessBuilding;
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
import nl.requios.effortlessbuilding.buildmode.ModeSettingsManager; import nl.requios.effortlessbuilding.buildmode.ModeSettingsManager;
import nl.requios.effortlessbuilding.proxy.ClientProxy; import nl.requios.effortlessbuilding.proxy.ClientProxy;
import org.apache.commons.lang3.text.WordUtils; import org.apache.commons.lang3.text.WordUtils;
@@ -16,14 +17,11 @@ import org.lwjgl.opengl.GL11;
import com.google.common.base.Stopwatch; import com.google.common.base.Stopwatch;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats; 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.BuildModes.*;
import static nl.requios.effortlessbuilding.buildmode.ModeOptions.*; import static nl.requios.effortlessbuilding.buildmode.ModeOptions.*;
@@ -32,7 +30,7 @@ import static nl.requios.effortlessbuilding.buildmode.ModeOptions.*;
* From Chisels and Bits by AlgorithmX2 * 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 * 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; private final float TIME_SCALE = 0.01f;
public static final RadialMenu instance = new RadialMenu(); public static final RadialMenu instance = new RadialMenu();
@@ -66,8 +64,8 @@ public class RadialMenu extends GuiScreen {
} }
public void configure(final int scaledWidth, final int scaledHeight ) { public void configure(final int scaledWidth, final int scaledHeight ) {
mc = Minecraft.getInstance(); Minecraft mc = Minecraft.getInstance();
fontRenderer = mc.fontRenderer; font = mc.fontRenderer;
width = scaledWidth; width = scaledWidth;
height = scaledHeight; height = scaledHeight;
} }
@@ -80,10 +78,10 @@ public class RadialMenu extends GuiScreen {
public final ActionEnum action; public final ActionEnum action;
public String name; public String name;
public EnumFacing textSide; public Direction textSide;
public MenuButton(final String name, final ActionEnum action, final double x, final double y, 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.name = I18n.format(name);
this.action = action; this.action = action;
x1 = x - 10; x1 = x - 10;
@@ -122,7 +120,7 @@ public class RadialMenu extends GuiScreen {
drawGradientRect(0, 0, width, height, startColor, endColor); drawGradientRect(0, 0, width, height, startColor, endColor);
GlStateManager.disableTexture2D(); GlStateManager.disableTexture();
GlStateManager.enableBlend(); GlStateManager.enableBlend();
GlStateManager.disableAlphaTest(); GlStateManager.disableAlphaTest();
GlStateManager.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); GlStateManager.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
@@ -158,17 +156,17 @@ public class RadialMenu extends GuiScreen {
} }
//Add actions //Add actions
buttons.add(new MenuButton(ActionEnum.UNDO.name, ActionEnum.UNDO, -buttonDistance - 26, -13, EnumFacing.UP)); buttons.add(new MenuButton(ActionEnum.UNDO.name, ActionEnum.UNDO, -buttonDistance - 26, -13, Direction.UP));
buttons.add(new MenuButton(ActionEnum.REDO.name, ActionEnum.REDO, -buttonDistance, -13, EnumFacing.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, EnumFacing.DOWN)); buttons.add(new MenuButton(ActionEnum.OPEN_MODIFIER_SETTINGS.name, ActionEnum.OPEN_MODIFIER_SETTINGS, -buttonDistance - 26, 13, Direction.DOWN));
buttons.add(new MenuButton(ActionEnum.REPLACE.name, ActionEnum.REPLACE, -buttonDistance, 13, EnumFacing.DOWN)); buttons.add(new MenuButton(ActionEnum.REPLACE.name, ActionEnum.REPLACE, -buttonDistance, 13, Direction.DOWN));
//Add buildmode dependent options //Add buildmode dependent options
OptionEnum[] options = currentBuildMode.options; OptionEnum[] options = currentBuildMode.options;
for (int i = 0; i < options.length; i++) { for (int i = 0; i < options.length; i++) {
for (int j = 0; j < options[i].actions.length; j++) { for (int j = 0; j < options[i].actions.length; j++) {
ActionEnum action = options[i].actions[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));
} }
} }
@@ -345,16 +343,16 @@ public class RadialMenu extends GuiScreen {
tessellator.draw(); tessellator.draw();
//Draw strings //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 //Draw option strings
for (int i = 0; i < currentBuildMode.options.length; i++) { for (int i = 0; i < currentBuildMode.options.length; i++) {
OptionEnum option = options[i]; OptionEnum option = options[i];
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"; 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 //Draw buildmode text
for (final MenuRegion menuRegion : modes) { for (final MenuRegion menuRegion : modes) {
@@ -364,16 +362,16 @@ public class RadialMenu extends GuiScreen {
final double y = (menuRegion.y1 + menuRegion.y2) * 0.5; final double y = (menuRegion.y1 + menuRegion.y2) * 0.5;
int fixed_x = (int) (x * textDistance); 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); final String text = I18n.format(menuRegion.mode.name);
if ( x <= -0.2 ) { if ( x <= -0.2 ) {
fixed_x -= fontRenderer.getStringWidth(text); fixed_x -= font.getStringWidth(text);
} else if ( -0.2 <= x && x <= 0.2 ) { } 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);
} }
} }
@@ -408,30 +406,30 @@ public class RadialMenu extends GuiScreen {
} }
if (!keybind.isEmpty()) keybindFormatted = TextFormatting.GRAY + "(" + WordUtils.capitalizeFully(keybind) + ")"; 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); (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); (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); (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); (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); (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); (int) (middleY + button.y1 + 38), wrap, 0xffffffff);
} }

View File

@@ -1,7 +1,7 @@
package nl.requios.effortlessbuilding.gui.buildmodifier; package nl.requios.effortlessbuilding.gui.buildmodifier;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
@@ -15,7 +15,6 @@ import nl.requios.effortlessbuilding.gui.elements.GuiNumberField;
import nl.requios.effortlessbuilding.gui.elements.GuiScrollPane; import nl.requios.effortlessbuilding.gui.elements.GuiScrollPane;
import nl.requios.effortlessbuilding.helper.ReachHelper; import nl.requios.effortlessbuilding.helper.ReachHelper;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -32,11 +31,11 @@ public class ArraySettingsGui extends GuiCollapsibleScrollEntry {
} }
@Override @Override
public int initGui(int id, List<GuiButton> buttons) { public int initGui(int id, List<Button> buttons) {
id = super.initGui(id, buttons); id = super.initGui(id, buttons);
int y = top; int y = top;
buttonArrayEnabled = new GuiCheckBox(id++, left - 15 + 8, y, "", false) { buttonArrayEnabled = new GuiCheckBox(left - 15 + 8, y, "", false) {
@Override @Override
public void onClick(double mouseX, double mouseY) { public void onClick(double mouseX, double mouseY) {
super.onClick(mouseX, mouseY); super.onClick(mouseX, mouseY);
@@ -46,23 +45,23 @@ public class ArraySettingsGui extends GuiCollapsibleScrollEntry {
buttons.add(buttonArrayEnabled); buttons.add(buttonArrayEnabled);
y = top + 20; y = top + 20;
textArrayOffsetX = new GuiNumberField(id++, id++, id++, fontRenderer, buttons, left + 70, y, 50, 18); textArrayOffsetX = new GuiNumberField(id++, id++, id++, font, buttons, left + 70, y, 50, 18);
textArrayOffsetX.setNumber(0); textArrayOffsetX.setNumber(0);
textArrayOffsetX.setTooltip("How much each copy is shifted."); textArrayOffsetX.setTooltip("How much each copy is shifted.");
arrayNumberFieldList.add(textArrayOffsetX); arrayNumberFieldList.add(textArrayOffsetX);
textArrayOffsetY = new GuiNumberField(id++, id++, id++, fontRenderer, buttons, left + 140, y, 50, 18); textArrayOffsetY = new GuiNumberField(id++, id++, id++, font, buttons, left + 140, y, 50, 18);
textArrayOffsetY.setNumber(0); textArrayOffsetY.setNumber(0);
textArrayOffsetY.setTooltip("How much each copy is shifted."); textArrayOffsetY.setTooltip("How much each copy is shifted.");
arrayNumberFieldList.add(textArrayOffsetY); arrayNumberFieldList.add(textArrayOffsetY);
textArrayOffsetZ = new GuiNumberField(id++, id++, id++, fontRenderer, buttons, left + 210, y, 50, 18); textArrayOffsetZ = new GuiNumberField(id++, id++, id++, font, buttons, left + 210, y, 50, 18);
textArrayOffsetZ.setNumber(0); textArrayOffsetZ.setNumber(0);
textArrayOffsetZ.setTooltip("How much each copy is shifted."); textArrayOffsetZ.setTooltip("How much each copy is shifted.");
arrayNumberFieldList.add(textArrayOffsetZ); arrayNumberFieldList.add(textArrayOffsetZ);
y = top + 50; y = top + 50;
textArrayCount = new GuiNumberField(id++, id++, id++, fontRenderer, buttons, left + 55, y, 50, 18); textArrayCount = new GuiNumberField(id++, id++, id++, font, buttons, left + 55, y, 50, 18);
textArrayCount.setNumber(5); textArrayCount.setNumber(5);
textArrayCount.setTooltip("How many copies should be made."); textArrayCount.setTooltip("How many copies should be made.");
arrayNumberFieldList.add(textArrayCount); arrayNumberFieldList.add(textArrayCount);
@@ -95,36 +94,36 @@ public class ArraySettingsGui extends GuiCollapsibleScrollEntry {
buttonArrayEnabled.render(mouseX, mouseY, partialTicks); buttonArrayEnabled.render(mouseX, mouseY, partialTicks);
if (buttonArrayEnabled.isChecked()) { if (buttonArrayEnabled.isChecked()) {
buttonArrayEnabled.y = yy; buttonArrayEnabled.y = yy;
fontRenderer.drawString("Array enabled", left + offset, yy + 2, 0xFFFFFF); font.drawString("Array enabled", left + offset, yy + 2, 0xFFFFFF);
yy = y + 20; yy = y + 20;
fontRenderer.drawString("Offset", left + offset, yy + 5, 0xFFFFFF); font.drawString("Offset", left + offset, yy + 5, 0xFFFFFF);
fontRenderer.drawString("X", left + 50 + offset, yy + 5, 0xFFFFFF); font.drawString("X", left + 50 + offset, yy + 5, 0xFFFFFF);
textArrayOffsetX.y = yy; textArrayOffsetX.y = yy;
fontRenderer.drawString("Y", left + 120 + offset, yy + 5, 0xFFFFFF); font.drawString("Y", left + 120 + offset, yy + 5, 0xFFFFFF);
textArrayOffsetY.y = yy; textArrayOffsetY.y = yy;
fontRenderer.drawString("Z", left + 190 + offset, yy + 5, 0xFFFFFF); font.drawString("Z", left + 190 + offset, yy + 5, 0xFFFFFF);
textArrayOffsetZ.y = yy; textArrayOffsetZ.y = yy;
yy = y + 50; yy = y + 50;
fontRenderer.drawString("Count", left + offset, yy + 5, 0xFFFFFF); font.drawString("Count", left + offset, yy + 5, 0xFFFFFF);
textArrayCount.y = yy; textArrayCount.y = yy;
int currentReach = Math.max(-1, getArrayReach()); int currentReach = Math.max(-1, getArrayReach());
int maxReach = ReachHelper.getMaxReach(mc.player); int maxReach = ReachHelper.getMaxReach(mc.player);
TextFormatting reachColor = isCurrentReachValid(currentReach, maxReach) ? TextFormatting.GRAY : TextFormatting.RED; TextFormatting reachColor = isCurrentReachValid(currentReach, maxReach) ? TextFormatting.GRAY : TextFormatting.RED;
String reachText = "Reach: " + reachColor + currentReach + TextFormatting.GRAY + "/" + TextFormatting.GRAY + maxReach; 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)); arrayNumberFieldList.forEach(numberField -> numberField.drawNumberField(mouseX, mouseY, partialTicks));
} else { } else {
buttonArrayEnabled.y = yy; 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 //Draw tooltips last
if (buttonArrayEnabled.isChecked()) if (buttonArrayEnabled.isChecked())
{ {
@@ -148,7 +147,7 @@ public class ArraySettingsGui extends GuiCollapsibleScrollEntry {
boolean insideArrayEnabledLabel = mouseX >= left && mouseX < right && relativeY >= -2 && relativeY < 12; boolean insideArrayEnabledLabel = mouseX >= left && mouseX < right && relativeY >= -2 && relativeY < 12;
if (insideArrayEnabledLabel) { if (insideArrayEnabledLabel) {
buttonArrayEnabled.playPressSound(this.mc.getSoundHandler()); buttonArrayEnabled.playDownSound(this.mc.getSoundHandler());
buttonArrayEnabled.onClick(mouseX, mouseY); buttonArrayEnabled.onClick(mouseX, mouseY);
} }

View File

@@ -1,7 +1,7 @@
package nl.requios.effortlessbuilding.gui.buildmodifier; package nl.requios.effortlessbuilding.gui.buildmodifier;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.screen.Screen;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TextFormatting;
@@ -17,7 +17,6 @@ import nl.requios.effortlessbuilding.gui.elements.GuiNumberField;
import nl.requios.effortlessbuilding.gui.elements.GuiScrollPane; import nl.requios.effortlessbuilding.gui.elements.GuiScrollPane;
import nl.requios.effortlessbuilding.helper.ReachHelper; import nl.requios.effortlessbuilding.helper.ReachHelper;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@@ -28,7 +27,7 @@ public class MirrorSettingsGui extends GuiCollapsibleScrollEntry {
protected static final ResourceLocation BUILDING_ICONS = new ResourceLocation(EffortlessBuilding.MODID, "textures/gui/building_icons.png"); 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<GuiIconButton> mirrorIconButtonList = new ArrayList<>();
protected List<GuiNumberField> mirrorNumberFieldList = new ArrayList<>(); protected List<GuiNumberField> mirrorNumberFieldList = new ArrayList<>();
@@ -42,11 +41,11 @@ public class MirrorSettingsGui extends GuiCollapsibleScrollEntry {
} }
@Override @Override
public int initGui(int id, List<GuiButton> buttonList) { public int initGui(int id, List<Button> buttonList) {
id = super.initGui(id, buttonList); id = super.initGui(id, buttonList);
int y = top - 2; int y = top - 2;
buttonMirrorEnabled = new GuiCheckBox(id++, left - 15 + 8, y, "", false) { buttonMirrorEnabled = new GuiCheckBox(left - 15 + 8, y, "", false) {
@Override @Override
public void onClick(double mouseX, double mouseY) { public void onClick(double mouseX, double mouseY) {
super.onClick(mouseX, mouseY); super.onClick(mouseX, mouseY);
@@ -56,34 +55,34 @@ public class MirrorSettingsGui extends GuiCollapsibleScrollEntry {
buttonList.add(buttonMirrorEnabled); buttonList.add(buttonMirrorEnabled);
y = top + 18; y = top + 18;
textMirrorPosX = new GuiNumberField(id++, id++, id++, fontRenderer, buttonList, left + 58, y, 62, 18); textMirrorPosX = new GuiNumberField(id++, id++, id++, font, buttonList, left + 58, y, 62, 18);
textMirrorPosX.setNumber(0); textMirrorPosX.setNumber(0);
textMirrorPosX.setTooltip( textMirrorPosX.setTooltip(
Arrays.asList("The position of the mirror.", TextFormatting.GRAY + "For odd numbered builds add 0.5.")); Arrays.asList("The position of the mirror.", TextFormatting.GRAY + "For odd numbered builds add 0.5."));
mirrorNumberFieldList.add(textMirrorPosX); mirrorNumberFieldList.add(textMirrorPosX);
textMirrorPosY = new GuiNumberField(id++, id++, id++, fontRenderer, buttonList, left + 138, y, 62, 18); textMirrorPosY = new GuiNumberField(id++, id++, id++, font, buttonList, left + 138, y, 62, 18);
textMirrorPosY.setNumber(64); textMirrorPosY.setNumber(64);
textMirrorPosY.setTooltip(Arrays.asList("The position of the mirror.", TextFormatting.GRAY + "For odd numbered builds add 0.5.")); textMirrorPosY.setTooltip(Arrays.asList("The position of the mirror.", TextFormatting.GRAY + "For odd numbered builds add 0.5."));
mirrorNumberFieldList.add(textMirrorPosY); mirrorNumberFieldList.add(textMirrorPosY);
textMirrorPosZ = new GuiNumberField(id++, id++, id++, fontRenderer, buttonList, left + 218, y, 62, 18); textMirrorPosZ = new GuiNumberField(id++, id++, id++, font, buttonList, left + 218, y, 62, 18);
textMirrorPosZ.setNumber(0); textMirrorPosZ.setNumber(0);
textMirrorPosZ.setTooltip(Arrays.asList("The position of the mirror.", TextFormatting.GRAY + "For odd numbered builds add 0.5.")); textMirrorPosZ.setTooltip(Arrays.asList("The position of the mirror.", TextFormatting.GRAY + "For odd numbered builds add 0.5."));
mirrorNumberFieldList.add(textMirrorPosZ); mirrorNumberFieldList.add(textMirrorPosZ);
y = top + 50; y = top + 50;
buttonMirrorX = new GuiCheckBox(id++, left + 60, y, " X", true); buttonMirrorX = new GuiCheckBox(left + 60, y, " X", true);
mirrorButtonList.add(buttonMirrorX); mirrorButtonList.add(buttonMirrorX);
buttonMirrorY = new GuiCheckBox(id++, left + 100, y, " Y", false); buttonMirrorY = new GuiCheckBox(left + 100, y, " Y", false);
mirrorButtonList.add(buttonMirrorY); mirrorButtonList.add(buttonMirrorY);
buttonMirrorZ = new GuiCheckBox(id++, left + 140, y, " Z", false); buttonMirrorZ = new GuiCheckBox(left + 140, y, " Z", false);
mirrorButtonList.add(buttonMirrorZ); mirrorButtonList.add(buttonMirrorZ);
y = top + 47; y = top + 47;
textMirrorRadius = new GuiNumberField(id++, id++, id++, fontRenderer, buttonList, left + 218, y, 62, 18); textMirrorRadius = new GuiNumberField(id++, id++, id++, font, buttonList, left + 218, y, 62, 18);
textMirrorRadius.setNumber(50); textMirrorRadius.setNumber(50);
//TODO change to diameter (remove /2) //TODO change to diameter (remove /2)
textMirrorRadius.setTooltip(Arrays.asList("How far the mirror reaches in any direction.", textMirrorRadius.setTooltip(Arrays.asList("How far the mirror reaches in any direction.",
@@ -202,23 +201,23 @@ public class MirrorSettingsGui extends GuiCollapsibleScrollEntry {
buttonMirrorEnabled.render(mouseX, mouseY, partialTicks); buttonMirrorEnabled.render(mouseX, mouseY, partialTicks);
if (buttonMirrorEnabled.isChecked()) { if (buttonMirrorEnabled.isChecked()) {
buttonMirrorEnabled.y = yy; buttonMirrorEnabled.y = yy;
fontRenderer.drawString("Mirror enabled", left + offset, yy + 2, 0xFFFFFF); font.drawString("Mirror enabled", left + offset, yy + 2, 0xFFFFFF);
yy = y + 18; yy = y + 18;
fontRenderer.drawString("Position", left + offset, yy + 5, 0xFFFFFF); font.drawString("Position", left + offset, yy + 5, 0xFFFFFF);
fontRenderer.drawString("X", left + 40 + offset, yy + 5, 0xFFFFFF); font.drawString("X", left + 40 + offset, yy + 5, 0xFFFFFF);
textMirrorPosX.y = yy; textMirrorPosX.y = yy;
fontRenderer.drawString("Y", left + 120 + offset, yy + 5, 0xFFFFFF); font.drawString("Y", left + 120 + offset, yy + 5, 0xFFFFFF);
textMirrorPosY.y = yy; textMirrorPosY.y = yy;
fontRenderer.drawString("Z", left + 200 + offset, yy + 5, 0xFFFFFF); font.drawString("Z", left + 200 + offset, yy + 5, 0xFFFFFF);
textMirrorPosZ.y = yy; textMirrorPosZ.y = yy;
yy = y + 50; yy = y + 50;
fontRenderer.drawString("Direction", left + offset, yy + 2, 0xFFFFFF); font.drawString("Direction", left + offset, yy + 2, 0xFFFFFF);
buttonMirrorX.y = yy; buttonMirrorX.y = yy;
buttonMirrorY.y = yy; buttonMirrorY.y = yy;
buttonMirrorZ.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; textMirrorRadius.y = yy - 3;
yy = y + 72; yy = y + 72;
@@ -232,12 +231,12 @@ public class MirrorSettingsGui extends GuiCollapsibleScrollEntry {
mirrorNumberFieldList.forEach(numberField -> numberField.drawNumberField(mouseX, mouseY, partialTicks)); mirrorNumberFieldList.forEach(numberField -> numberField.drawNumberField(mouseX, mouseY, partialTicks));
} else { } else {
buttonMirrorEnabled.y = yy; 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 //Draw tooltips last
if (buttonMirrorEnabled.isChecked()) if (buttonMirrorEnabled.isChecked())
{ {
@@ -262,7 +261,7 @@ public class MirrorSettingsGui extends GuiCollapsibleScrollEntry {
boolean insideMirrorEnabledLabel = mouseX >= left && mouseX < right && relativeY >= -2 && relativeY < 12; boolean insideMirrorEnabledLabel = mouseX >= left && mouseX < right && relativeY >= -2 && relativeY < 12;
if (insideMirrorEnabledLabel) { if (insideMirrorEnabledLabel) {
buttonMirrorEnabled.playPressSound(this.mc.getSoundHandler()); buttonMirrorEnabled.playDownSound(this.mc.getSoundHandler());
buttonMirrorEnabled.onClick(mouseX, mouseY); buttonMirrorEnabled.onClick(mouseX, mouseY);
} }

View File

@@ -1,8 +1,8 @@
package nl.requios.effortlessbuilding.gui.buildmodifier; package nl.requios.effortlessbuilding.gui.buildmodifier;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.widget.button.Button;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import nl.requios.effortlessbuilding.EffortlessBuilding; import nl.requios.effortlessbuilding.EffortlessBuilding;
@@ -15,13 +15,11 @@ import nl.requios.effortlessbuilding.network.ModifierSettingsMessage;
import nl.requios.effortlessbuilding.network.PacketHandler; import nl.requios.effortlessbuilding.network.PacketHandler;
import nl.requios.effortlessbuilding.proxy.ClientProxy; import nl.requios.effortlessbuilding.proxy.ClientProxy;
import java.io.IOException;
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public class ModifierSettingsGui extends GuiScreen { public class ModifierSettingsGui extends Screen {
private GuiScrollPane scrollPane; private GuiScrollPane scrollPane;
private GuiButton buttonClose; private Button buttonClose;
private MirrorSettingsGui mirrorSettingsGui; private MirrorSettingsGui mirrorSettingsGui;
private ArraySettingsGui arraySettingsGui; private ArraySettingsGui arraySettingsGui;
@@ -32,7 +30,7 @@ public class ModifierSettingsGui extends GuiScreen {
public void initGui() { public void initGui() {
int id = 0; int id = 0;
scrollPane = new GuiScrollPane(this, fontRenderer, 8, height - 30); scrollPane = new GuiScrollPane(this, font, 8, height - 30);
mirrorSettingsGui = new MirrorSettingsGui(scrollPane); mirrorSettingsGui = new MirrorSettingsGui(scrollPane);
scrollPane.AddListEntry(mirrorSettingsGui); scrollPane.AddListEntry(mirrorSettingsGui);
@@ -47,11 +45,11 @@ public class ModifierSettingsGui extends GuiScreen {
//Close button //Close button
int y = height - 26; int y = height - 26;
buttonClose = new GuiButton(id++, width / 2 - 100, y, "Close") { buttonClose = new Button(width / 2 - 100, y, "Close") {
@Override @Override
public void onClick(double mouseX, double mouseY) { public void onClick(double mouseX, double mouseY) {
super.onClick(mouseX, mouseY); super.onClick(mouseX, mouseY);
mc.player.closeScreen(); Minecraft.getInstance().player.closeScreen();
} }
}; };
buttons.add(buttonClose); buttons.add(buttonClose);
@@ -67,7 +65,7 @@ public class ModifierSettingsGui extends GuiScreen {
} }
@Override @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 //Use drawTexturedModalRect() to transfers areas of a texture resource to the screen
public void render(int mouseX, int mouseY, float partialTicks) { public void render(int mouseX, int mouseY, float partialTicks) {
this.drawDefaultBackground(); this.drawDefaultBackground();

View File

@@ -1,7 +1,7 @@
package nl.requios.effortlessbuilding.gui.buildmodifier; package nl.requios.effortlessbuilding.gui.buildmodifier;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.screen.Screen;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TextFormatting;
@@ -17,7 +17,6 @@ import nl.requios.effortlessbuilding.gui.elements.GuiNumberField;
import nl.requios.effortlessbuilding.gui.elements.GuiScrollPane; import nl.requios.effortlessbuilding.gui.elements.GuiScrollPane;
import nl.requios.effortlessbuilding.helper.ReachHelper; import nl.requios.effortlessbuilding.helper.ReachHelper;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@@ -28,7 +27,7 @@ public class RadialMirrorSettingsGui extends GuiCollapsibleScrollEntry {
protected static final ResourceLocation BUILDING_ICONS = new ResourceLocation(EffortlessBuilding.MODID, "textures/gui/building_icons.png"); 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<GuiIconButton> radialMirrorIconButtonList = new ArrayList<>();
protected List<GuiNumberField> radialMirrorNumberFieldList = new ArrayList<>(); protected List<GuiNumberField> radialMirrorNumberFieldList = new ArrayList<>();
@@ -42,11 +41,11 @@ public class RadialMirrorSettingsGui extends GuiCollapsibleScrollEntry {
} }
@Override @Override
public int initGui(int id, List<GuiButton> buttonList) { public int initGui(int id, List<Button> buttonList) {
id = super.initGui(id, buttonList); id = super.initGui(id, buttonList);
int y = top - 2; int y = top - 2;
buttonRadialMirrorEnabled = new GuiCheckBox(id++, left - 15 + 8, y, "", false) { buttonRadialMirrorEnabled = new GuiCheckBox(left - 15 + 8, y, "", false) {
@Override @Override
public void onClick(double mouseX, double mouseY) { public void onClick(double mouseX, double mouseY) {
super.onClick(mouseX, mouseY); super.onClick(mouseX, mouseY);
@@ -56,29 +55,29 @@ public class RadialMirrorSettingsGui extends GuiCollapsibleScrollEntry {
buttonList.add(buttonRadialMirrorEnabled); buttonList.add(buttonRadialMirrorEnabled);
y = top + 18; y = top + 18;
textRadialMirrorPosX = new GuiNumberField(id++, id++, id++, fontRenderer, buttonList, left + 58, y, 62, 18); textRadialMirrorPosX = new GuiNumberField(id++, id++, id++, font, buttonList, left + 58, y, 62, 18);
textRadialMirrorPosX.setNumber(0); textRadialMirrorPosX.setNumber(0);
textRadialMirrorPosX.setTooltip( textRadialMirrorPosX.setTooltip(
Arrays.asList("The position of the radial mirror.", TextFormatting.GRAY + "For odd numbered builds add 0.5.")); Arrays.asList("The position of the radial mirror.", TextFormatting.GRAY + "For odd numbered builds add 0.5."));
radialMirrorNumberFieldList.add(textRadialMirrorPosX); radialMirrorNumberFieldList.add(textRadialMirrorPosX);
textRadialMirrorPosY = new GuiNumberField(id++, id++, id++, fontRenderer, buttonList, left + 138, y, 62, 18); textRadialMirrorPosY = new GuiNumberField(id++, id++, id++, font, buttonList, left + 138, y, 62, 18);
textRadialMirrorPosY.setNumber(64); textRadialMirrorPosY.setNumber(64);
textRadialMirrorPosY.setTooltip(Arrays.asList("The position of the radial mirror.", TextFormatting.GRAY + "For odd numbered builds add 0.5.")); textRadialMirrorPosY.setTooltip(Arrays.asList("The position of the radial mirror.", TextFormatting.GRAY + "For odd numbered builds add 0.5."));
radialMirrorNumberFieldList.add(textRadialMirrorPosY); radialMirrorNumberFieldList.add(textRadialMirrorPosY);
textRadialMirrorPosZ = new GuiNumberField(id++, id++, id++, fontRenderer, buttonList, left + 218, y, 62, 18); textRadialMirrorPosZ = new GuiNumberField(id++, id++, id++, font, buttonList, left + 218, y, 62, 18);
textRadialMirrorPosZ.setNumber(0); textRadialMirrorPosZ.setNumber(0);
textRadialMirrorPosZ.setTooltip(Arrays.asList("The position of the radial mirror.", TextFormatting.GRAY + "For odd numbered builds add 0.5.")); textRadialMirrorPosZ.setTooltip(Arrays.asList("The position of the radial mirror.", TextFormatting.GRAY + "For odd numbered builds add 0.5."));
radialMirrorNumberFieldList.add(textRadialMirrorPosZ); radialMirrorNumberFieldList.add(textRadialMirrorPosZ);
y = top + 47; y = top + 47;
textRadialMirrorSlices = new GuiNumberField(id++, id++, id++, fontRenderer, buttonList, left + 55, y, 50, 18); textRadialMirrorSlices = new GuiNumberField(id++, id++, id++, font, buttonList, left + 55, y, 50, 18);
textRadialMirrorSlices.setNumber(4); textRadialMirrorSlices.setNumber(4);
textRadialMirrorSlices.setTooltip(Arrays.asList("The number of repeating slices.", TextFormatting.GRAY + "Minimally 2.")); textRadialMirrorSlices.setTooltip(Arrays.asList("The number of repeating slices.", TextFormatting.GRAY + "Minimally 2."));
radialMirrorNumberFieldList.add(textRadialMirrorSlices); radialMirrorNumberFieldList.add(textRadialMirrorSlices);
textRadialMirrorRadius = new GuiNumberField(id++, id++, id++, fontRenderer, buttonList, left + 218, y, 62, 18); textRadialMirrorRadius = new GuiNumberField(id++, id++, id++, font, buttonList, left + 218, y, 62, 18);
textRadialMirrorRadius.setNumber(50); textRadialMirrorRadius.setNumber(50);
//TODO change to diameter (remove /2) //TODO change to diameter (remove /2)
textRadialMirrorRadius.setTooltip(Arrays.asList("How far the radial mirror reaches from its center position.", textRadialMirrorRadius.setTooltip(Arrays.asList("How far the radial mirror reaches from its center position.",
@@ -147,7 +146,7 @@ public class RadialMirrorSettingsGui extends GuiCollapsibleScrollEntry {
radialMirrorIconButtonList.add(buttonDrawPlanes); radialMirrorIconButtonList.add(buttonDrawPlanes);
y = top + 76; y = top + 76;
buttonRadialMirrorAlternate = new GuiCheckBox(id++, left + 140, y, " Alternate", false); buttonRadialMirrorAlternate = new GuiCheckBox(left + 140, y, " Alternate", false);
radialMirrorButtonList.add(buttonRadialMirrorAlternate); radialMirrorButtonList.add(buttonRadialMirrorAlternate);
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(mc.player); ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(mc.player);
@@ -199,21 +198,21 @@ public class RadialMirrorSettingsGui extends GuiCollapsibleScrollEntry {
buttonRadialMirrorEnabled.render(mouseX, mouseY, partialTicks); buttonRadialMirrorEnabled.render(mouseX, mouseY, partialTicks);
if (buttonRadialMirrorEnabled.isChecked()) { if (buttonRadialMirrorEnabled.isChecked()) {
buttonRadialMirrorEnabled.y = yy; 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; yy = y + 18;
fontRenderer.drawString("Position", left + offset, yy + 5, 0xFFFFFF); font.drawString("Position", left + offset, yy + 5, 0xFFFFFF);
fontRenderer.drawString("X", left + 40 + offset, yy + 5, 0xFFFFFF); font.drawString("X", left + 40 + offset, yy + 5, 0xFFFFFF);
textRadialMirrorPosX.y = yy; textRadialMirrorPosX.y = yy;
fontRenderer.drawString("Y", left + 120 + offset, yy + 5, 0xFFFFFF); font.drawString("Y", left + 120 + offset, yy + 5, 0xFFFFFF);
textRadialMirrorPosY.y = yy; textRadialMirrorPosY.y = yy;
fontRenderer.drawString("Z", left + 200 + offset, yy + 5, 0xFFFFFF); font.drawString("Z", left + 200 + offset, yy + 5, 0xFFFFFF);
textRadialMirrorPosZ.y = yy; textRadialMirrorPosZ.y = yy;
yy = y + 50; yy = y + 50;
fontRenderer.drawString("Slices", left + offset, yy + 2, 0xFFFFFF); font.drawString("Slices", left + offset, yy + 2, 0xFFFFFF);
textRadialMirrorSlices.y = yy - 3; 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; textRadialMirrorRadius.y = yy - 3;
yy = y + 72; yy = y + 72;
@@ -231,12 +230,12 @@ public class RadialMirrorSettingsGui extends GuiCollapsibleScrollEntry {
.forEach(numberField -> numberField.drawNumberField(mouseX, mouseY, partialTicks)); .forEach(numberField -> numberField.drawNumberField(mouseX, mouseY, partialTicks));
} else { } else {
buttonRadialMirrorEnabled.y = yy; 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 //Draw tooltips last
if (buttonRadialMirrorEnabled.isChecked()) if (buttonRadialMirrorEnabled.isChecked())
{ {
@@ -261,7 +260,7 @@ public class RadialMirrorSettingsGui extends GuiCollapsibleScrollEntry {
boolean insideRadialMirrorEnabledLabel = mouseX >= left && mouseX < right && relativeY >= -2 && relativeY < 12; boolean insideRadialMirrorEnabledLabel = mouseX >= left && mouseX < right && relativeY >= -2 && relativeY < 12;
if (insideRadialMirrorEnabledLabel) { if (insideRadialMirrorEnabledLabel) {
buttonRadialMirrorEnabled.playPressSound(this.mc.getSoundHandler()); buttonRadialMirrorEnabled.playDownSound(this.mc.getSoundHandler());
buttonRadialMirrorEnabled.onClick(mouseX, mouseY); buttonRadialMirrorEnabled.onClick(mouseX, mouseY);
} }

View File

@@ -2,20 +2,19 @@ package nl.requios.effortlessbuilding.gui.elements;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.font;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.gui.IGuiEventListener; import net.minecraft.client.gui.screen.Screen;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import java.io.IOException;
import java.util.List; import java.util.List;
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public abstract class GuiCollapsibleScrollEntry implements GuiScrollPane.IScrollEntry { public abstract class GuiCollapsibleScrollEntry implements GuiScrollPane.IScrollEntry {
public GuiScrollPane scrollPane; public GuiScrollPane scrollPane;
protected FontRenderer fontRenderer; protected FontRenderer font;
protected Minecraft mc; protected Minecraft mc;
protected boolean isCollapsed = true; protected boolean isCollapsed = true;
@@ -23,12 +22,12 @@ public abstract class GuiCollapsibleScrollEntry implements GuiScrollPane.IScroll
public GuiCollapsibleScrollEntry(GuiScrollPane scrollPane) { public GuiCollapsibleScrollEntry(GuiScrollPane scrollPane) {
this.scrollPane = scrollPane; this.scrollPane = scrollPane;
this.fontRenderer = scrollPane.fontRenderer; this.font = scrollPane.font;
this.mc = scrollPane.parent.mc; this.mc = Minecraft.getInstance();
} }
@Override @Override
public int initGui(int id, List<GuiButton> buttonList) { public int initGui(int id, List<Button> buttonList) {
left = scrollPane.width / 2 - 140; left = scrollPane.width / 2 - 140;
right = scrollPane.width / 2 + 140; right = scrollPane.width / 2 + 140;
@@ -43,7 +42,7 @@ public abstract class GuiCollapsibleScrollEntry implements GuiScrollPane.IScroll
} }
@Override @Override
public void drawTooltip(GuiScreen guiScreen, int mouseX, int mouseY) { public void drawTooltip(Screen guiScreen, int mouseX, int mouseY) {
} }
@Override @Override

View File

@@ -1,8 +1,8 @@
package nl.requios.effortlessbuilding.gui.elements; package nl.requios.effortlessbuilding.gui.elements;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.screen.Screen;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
@@ -12,7 +12,7 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public class GuiIconButton extends GuiButton { public class GuiIconButton extends Button {
private final ResourceLocation resourceLocation; private final ResourceLocation resourceLocation;
private final int iconX, iconY, iconWidth, iconHeight, iconAltX, iconAltY; private final int iconX, iconY, iconWidth, iconHeight, iconAltX, iconAltY;
@@ -66,7 +66,7 @@ public class GuiIconButton extends GuiButton {
} }
} }
public void drawTooltip(GuiScreen guiScreen, int mouseX, int mouseY) { public void drawTooltip(Screen guiScreen, int mouseX, int mouseY) {
boolean flag = mouseX >= x && mouseX < x + width && mouseY >= y && mouseY < y + height; boolean flag = mouseX >= x && mouseX < x + width && mouseY >= y && mouseY < y + height;
if (flag) { if (flag) {

View File

@@ -1,12 +1,13 @@
package nl.requios.effortlessbuilding.gui.elements; package nl.requios.effortlessbuilding.gui.elements;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.*; 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.button.Button;
import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import java.io.IOException;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.ParseException; import java.text.ParseException;
import java.util.ArrayList; import java.util.ArrayList;
@@ -14,40 +15,40 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public class GuiNumberField extends Gui { public class GuiNumberField extends AbstractGui {
public int x, y, width, height; public int x, y, width, height;
public int buttonWidth = 10; public int buttonWidth = 10;
protected GuiTextField textField; protected TextFieldWidget textField;
protected GuiButton minusButton, plusButton; protected Button minusButton, plusButton;
List<String> tooltip = new ArrayList<>(); List<String> tooltip = new ArrayList<>();
public GuiNumberField(int id1, int id2, int id3, FontRenderer fontRenderer, public GuiNumberField(int id1, int id2, int id3, FontRenderer font,
List<GuiButton> buttonList, int x, int y, int width, int height) { List<Button> buttonList, int x, int y, int width, int height) {
this.x = x; this.x = x;
this.y = y; this.y = y;
this.width = width; this.width = width;
this.height = height; this.height = height;
textField = new GuiTextField(id1, fontRenderer, x + buttonWidth + 1, y + 1, width - 2 * buttonWidth - 2, height - 2); textField = new TextFieldWidget(id1, font, x + buttonWidth + 1, y + 1, width - 2 * buttonWidth - 2, height - 2);
minusButton = new GuiButton(id2, x, y - 1, buttonWidth, height + 2, "-") { minusButton = new Button(id2, x, y - 1, buttonWidth, height + 2, "-") {
@Override @Override
public void onClick(double mouseX, double mouseY) { public void onClick(double mouseX, double mouseY) {
float valueChanged = 1f; float valueChanged = 1f;
if (GuiScreen.isCtrlKeyDown()) valueChanged = 5f; if (Screen.isCtrlKeyDown()) valueChanged = 5f;
if (GuiScreen.isShiftKeyDown()) valueChanged = 10f; if (Screen.isShiftKeyDown()) valueChanged = 10f;
setNumber(getNumber() - valueChanged); setNumber(getNumber() - valueChanged);
} }
}; };
plusButton = new GuiButton(id3, x + width - buttonWidth, y - 1, buttonWidth, height + 2, "+") { plusButton = new Button(id3, x + width - buttonWidth, y - 1, buttonWidth, height + 2, "+") {
@Override @Override
public void onClick(double mouseX, double mouseY) { public void onClick(double mouseX, double mouseY) {
float valueChanged = 1f; float valueChanged = 1f;
if (GuiScreen.isCtrlKeyDown()) valueChanged = 5f; if (Screen.isCtrlKeyDown()) valueChanged = 5f;
if (GuiScreen.isShiftKeyDown()) valueChanged = 10f; if (Screen.isShiftKeyDown()) valueChanged = 10f;
setNumber(getNumber() + valueChanged); setNumber(getNumber() + valueChanged);
} }
@@ -104,7 +105,7 @@ public class GuiNumberField extends Gui {
plusButton.render(mouseX, mouseY, partialTicks); plusButton.render(mouseX, mouseY, partialTicks);
} }
public void drawTooltip(GuiScreen guiScreen, int mouseX, int mouseY) { public void drawTooltip(Screen guiScreen, int mouseX, int mouseY) {
boolean insideTextField = mouseX >= x + buttonWidth && mouseX < x + width - buttonWidth && mouseY >= y && mouseY < y + height; 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 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; boolean insidePlusButton = mouseX >= x + width - buttonWidth && mouseX < x + width && mouseY >= y && mouseY < y + height;

View File

@@ -1,7 +1,10 @@
package nl.requios.effortlessbuilding.gui.elements; 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.*;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Tessellator;
@@ -13,31 +16,27 @@ import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.GuiScreenEvent; import net.minecraftforge.client.event.GuiScreenEvent;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.gameevent.TickEvent; 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.ArrayList;
import java.util.List; import java.util.List;
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public class GuiScrollPane extends GuiSlot { public class GuiScrollPane extends SlotGui {
public GuiScreen parent; public Screen parent;
public FontRenderer fontRenderer; public FontRenderer font;
private List<IScrollEntry> listEntries; private List<IScrollEntry> listEntries;
private float scrollMultiplier = 1f; private float scrollMultiplier = 1f;
private int mouseX; private int mouseX;
private int mouseY; private int mouseY;
public GuiScrollPane(GuiScreen parent, FontRenderer fontRenderer, int top, int bottom) { public GuiScrollPane(Screen parent, FontRenderer font, int top, int bottom) {
super(parent.mc, parent.width, parent.height, top, bottom, 100); super(Minecraft.getInstance(), parent.width, parent.height, top, bottom, 100);
this.parent = parent; this.parent = parent;
this.fontRenderer = fontRenderer; this.font = font;
this.setShowSelectionBox(false); this.renderSelection = false;
listEntries = new ArrayList<>(); listEntries = new ArrayList<>();
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
} }
@@ -443,7 +442,7 @@ public class GuiScrollPane extends GuiSlot {
} }
//PASSTHROUGHS //PASSTHROUGHS
public int initGui(int id, List<GuiButton> buttonList) { public int initGui(int id, List<Button> buttonList) {
for (IScrollEntry entry : this.listEntries) { for (IScrollEntry entry : this.listEntries) {
id = entry.initGui(id, buttonList); id = entry.initGui(id, buttonList);
} }
@@ -455,7 +454,7 @@ public class GuiScrollPane extends GuiSlot {
entry.updateScreen(); 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) for (IScrollEntry entry : this.listEntries)
entry.drawTooltip(guiScreen, mouseX, mouseY); entry.drawTooltip(guiScreen, mouseX, mouseY);
} }
@@ -473,11 +472,11 @@ public class GuiScrollPane extends GuiSlot {
} }
public interface IScrollEntry { public interface IScrollEntry {
int initGui(int id, List<GuiButton> buttonList); int initGui(int id, List<Button> buttonList);
void updateScreen(); void updateScreen();
void drawTooltip(GuiScreen guiScreen, int mouseX, int mouseY); void drawTooltip(Screen guiScreen, int mouseX, int mouseY);
boolean charTyped(char eventChar, int eventKey); boolean charTyped(char eventChar, int eventKey);

View File

@@ -1,28 +1,27 @@
package nl.requios.effortlessbuilding.helper; package nl.requios.effortlessbuilding.helper;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public class InventoryHelper { 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) { for (ItemStack invStack : player.inventory.mainInventory) {
if (!invStack.isEmpty() && invStack.getItem() instanceof ItemBlock && if (!invStack.isEmpty() && invStack.getItem() instanceof BlockItem &&
((ItemBlock) invStack.getItem()).getBlock().equals(block)) { ((BlockItem) invStack.getItem()).getBlock().equals(block)) {
return invStack; return invStack;
} }
} }
return ItemStack.EMPTY; return ItemStack.EMPTY;
} }
public static int findTotalBlocksInInventory(EntityPlayer player, Block block) { public static int findTotalBlocksInInventory(PlayerEntity player, Block block) {
int total = 0; int total = 0;
for (ItemStack invStack : player.inventory.mainInventory) { for (ItemStack invStack : player.inventory.mainInventory) {
if (!invStack.isEmpty() && invStack.getItem() instanceof ItemBlock && if (!invStack.isEmpty() && invStack.getItem() instanceof BlockItem &&
((ItemBlock) invStack.getItem()).getBlock().equals(block)) { ((BlockItem) invStack.getItem()).getBlock().equals(block)) {
total += invStack.getCount(); total += invStack.getCount();
} }
} }

View File

@@ -1,14 +1,28 @@
package nl.requios.effortlessbuilding.helper; package nl.requios.effortlessbuilding.helper;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import net.minecraftforge.common.crafting.IConditionSerializer; import net.minecraft.item.crafting.Ingredient;
import net.minecraft.network.PacketBuffer;
import net.minecraftforge.common.crafting.IIngredientSerializer;
import nl.requios.effortlessbuilding.BuildConfig; import nl.requios.effortlessbuilding.BuildConfig;
import java.util.function.BooleanSupplier; public class ReachConditionFactory implements IIngredientSerializer {
public class ReachConditionFactory implements IConditionSerializer {
@Override @Override
public BooleanSupplier parse(JsonObject json) { public Ingredient parse(PacketBuffer buffer) {
return () -> BuildConfig.reach.enableReachUpgrades.get(); if (BuildConfig.reach.enableReachUpgrades.get())
return Ingredient.read(buffer);
return Ingredient.EMPTY;
}
@Override
public Ingredient parse(JsonObject json) {
if (BuildConfig.reach.enableReachUpgrades.get())
return Ingredient.deserialize(json);
return Ingredient.EMPTY;
}
@Override
public void write(PacketBuffer buffer, Ingredient ingredient) {
ingredient.write(buffer);
} }
} }

View File

@@ -1,12 +1,12 @@
package nl.requios.effortlessbuilding.helper; package nl.requios.effortlessbuilding.helper;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import nl.requios.effortlessbuilding.BuildConfig; import nl.requios.effortlessbuilding.BuildConfig;
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager; import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
public class ReachHelper { public class ReachHelper {
public static int getMaxReach(EntityPlayer player) { public static int getMaxReach(PlayerEntity player) {
if (player.isCreative()) return BuildConfig.reach.maxReachCreative.get(); if (player.isCreative()) return BuildConfig.reach.maxReachCreative.get();
if (!BuildConfig.reach.enableReachUpgrades.get()) return BuildConfig.reach.maxReachLevel3.get(); if (!BuildConfig.reach.enableReachUpgrades.get()) return BuildConfig.reach.maxReachLevel3.get();
@@ -22,11 +22,11 @@ public class ReachHelper {
return BuildConfig.reach.maxReachLevel0.get(); return BuildConfig.reach.maxReachLevel0.get();
} }
public static int getPlacementReach(EntityPlayer player) { public static int getPlacementReach(PlayerEntity player) {
return getMaxReach(player) / 4; return getMaxReach(player) / 4;
} }
public static int getMaxBlocksPlacedAtOnce(EntityPlayer player) { public static int getMaxBlocksPlacedAtOnce(PlayerEntity player) {
if (player.isCreative()) return 1000000; if (player.isCreative()) return 1000000;
return MathHelper.ceil(Math.pow(getMaxReach(player), 1.6)); return MathHelper.ceil(Math.pow(getMaxReach(player), 1.6));
//Level 0: 121 //Level 0: 121
@@ -35,7 +35,7 @@ public class ReachHelper {
//Level 3: 4805 //Level 3: 4805
} }
public static int getMaxBlocksPerAxis(EntityPlayer player) { public static int getMaxBlocksPerAxis(PlayerEntity player) {
if (player.isCreative()) return 2000; if (player.isCreative()) return 2000;
return MathHelper.ceil(getMaxReach(player) * 0.3); return MathHelper.ceil(getMaxReach(player) * 0.3);
//Level 0: 6 //Level 0: 6
@@ -44,7 +44,7 @@ public class ReachHelper {
//Level 3: 60 //Level 3: 60
} }
public static boolean canBreakFar(EntityPlayer player) { public static boolean canBreakFar(PlayerEntity player) {
return player.isCreative() || BuildConfig.survivalBalancers.breakFar.get(); return player.isCreative() || BuildConfig.survivalBalancers.breakFar.get();
} }
} }

View File

@@ -1,28 +1,24 @@
package nl.requios.effortlessbuilding.helper; package nl.requios.effortlessbuilding.helper;
import net.minecraft.block.Block; import net.minecraft.block.*;
import net.minecraft.block.BlockSlab; import net.minecraft.block.SlabBlock;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.state.BlockWorldState; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.block.state.IBlockState; import net.minecraft.item.BlockItem;
import net.minecraft.util.*;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.block.Blocks;
import net.minecraft.init.Blocks;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult; import net.minecraft.util.CachedBlockInfo;
import net.minecraft.util.EnumFacing; import net.minecraft.util.Direction;
import net.minecraft.util.EnumHand; import net.minecraft.util.Hand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ToolType; import net.minecraftforge.common.ToolType;
import nl.requios.effortlessbuilding.BuildConfig; import nl.requios.effortlessbuilding.BuildConfig;
import nl.requios.effortlessbuilding.EffortlessBuilding;
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager; import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
import nl.requios.effortlessbuilding.compatibility.CompatHelper; import nl.requios.effortlessbuilding.compatibility.CompatHelper;
@@ -34,15 +30,15 @@ public class SurvivalHelper {
//Used for all placing of blocks in this mod. //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. //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 //Based on ItemBlock#onItemUse
public static boolean placeBlock(World world, EntityPlayer player, BlockPos pos, IBlockState blockState, public static boolean placeBlock(World world, PlayerEntity player, BlockPos pos, BlockState blockState,
ItemStack origstack, EnumFacing facing, Vec3d hitVec, boolean skipPlaceCheck, ItemStack origstack, Direction facing, Vec3d hitVec, boolean skipPlaceCheck,
boolean skipCollisionCheck, boolean playSound) { boolean skipCollisionCheck, boolean playSound) {
if (!world.isBlockLoaded(pos, true)) return false; if (!world.isBlockPresent(pos)) return false;
ItemStack itemstack = origstack; ItemStack itemstack = origstack;
if (blockState.getBlock().isAir(blockState, world, pos) || itemstack.isEmpty()) { if (blockState.getBlock().isAir(blockState, world, pos) || itemstack.isEmpty()) {
dropBlock(world, player, pos); dropBlock(world, player, pos);
world.removeBlock(pos); world.removeBlock(pos, false);
return true; return true;
} }
@@ -51,9 +47,9 @@ public class SurvivalHelper {
if (CompatHelper.isItemBlockProxy(itemstack)) if (CompatHelper.isItemBlockProxy(itemstack))
itemstack = CompatHelper.getItemBlockByState(itemstack, blockState); itemstack = CompatHelper.getItemBlockByState(itemstack, blockState);
if (!(itemstack.getItem() instanceof ItemBlock)) if (!(itemstack.getItem() instanceof BlockItem))
return false; return false;
Block block = ((ItemBlock) itemstack.getItem()).getBlock(); Block block = ((BlockItem) itemstack.getItem()).getBlock();
//More manual with ItemBlock#placeBlockAt //More manual with ItemBlock#placeBlockAt
@@ -77,7 +73,7 @@ public class SurvivalHelper {
// if (result != EnumActionResult.SUCCESS) return false; // if (result != EnumActionResult.SUCCESS) return false;
IBlockState afterState = world.getBlockState(pos); BlockState afterState = world.getBlockState(pos);
if (playSound) { if (playSound) {
SoundType soundtype = afterState.getBlock().getSoundType(afterState, world, pos, player); 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. //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 //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) { public static boolean breakBlock(World world, PlayerEntity player, BlockPos pos, boolean skipChecks) {
if (!world.isBlockLoaded(pos, false)) return false; if (!world.isBlockPresent(pos) && !world.isAirBlock(pos)) return false;
//Check if can break //Check if can break
if (skipChecks || canBreak(world, player, pos)) { if (skipChecks || canBreak(world, player, pos)) {
@@ -133,17 +129,17 @@ public class SurvivalHelper {
//Damage tool //Damage tool
player.getHeldItemMainhand().onBlockDestroyed(world, world.getBlockState(pos), pos, player); player.getHeldItemMainhand().onBlockDestroyed(world, world.getBlockState(pos), pos, player);
world.removeBlock(pos); world.removeBlock(pos, false);
return true; return true;
} }
return false; return false;
} }
//Gives items directly to player //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; if (player.isCreative()) return;
IBlockState blockState = world.getBlockState(pos); BlockState blockState = world.getBlockState(pos);
Block block = blockState.getBlock(); Block block = blockState.getBlock();
block.harvestBlock(world, player, pos, blockState, world.getTileEntity(pos), player.getHeldItemMainhand()); block.harvestBlock(world, player, pos, blockState, world.getTileEntity(pos), player.getHeldItemMainhand());
@@ -190,17 +186,17 @@ public class SurvivalHelper {
* @param sidePlacedOn * @param sidePlacedOn
* @return Whether the player may place the block at pos with itemstack * @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 //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(player, "Cannot (re)place block", true);
// EffortlessBuilding.log("SurvivalHelper#canPlace: itemstack " + itemStack.toString() + " does not match blockstate " + newBlockState.toString()); // EffortlessBuilding.log("SurvivalHelper#canPlace: itemstack " + itemStack.toString() + " does not match blockstate " + newBlockState.toString());
//Happens when breaking blocks, no need to notify in that case //Happens when breaking blocks, no need to notify in that case
return false; return false;
} }
Block block = ((ItemBlock) itemStack.getItem()).getBlock(); Block block = ((BlockItem) itemStack.getItem()).getBlock();
return !itemStack.isEmpty() && canPlayerEdit(player, world, pos, itemStack) && return !itemStack.isEmpty() && canPlayerEdit(player, world, pos, itemStack) &&
mayPlace(world, block, newBlockState, pos, skipCollisionCheck, sidePlacedOn, player) && mayPlace(world, block, newBlockState, pos, skipCollisionCheck, sidePlacedOn, player) &&
@@ -208,10 +204,10 @@ public class SurvivalHelper {
} }
//Can be harvested with hand? (or in creative) //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; if (player.isCreative()) return true;
IBlockState state = world.getBlockState(pos); BlockState state = world.getBlockState(pos);
switch (BuildConfig.survivalBalancers.quickReplaceMiningLevel.get()) { switch (BuildConfig.survivalBalancers.quickReplaceMiningLevel.get()) {
case -1: return state.getMaterial().isToolNotRequired(); case -1: return state.getMaterial().isToolNotRequired();
@@ -225,7 +221,7 @@ public class SurvivalHelper {
} }
//From EntityPlayer#canPlayerEdit //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; if (!world.isBlockModifiable(player, pos)) return false;
@@ -237,25 +233,25 @@ public class SurvivalHelper {
else else
{ {
//Adventure mode //Adventure mode
BlockWorldState blockworldstate = new BlockWorldState(world, pos, false); CachedBlockInfo blockworldstate = new CachedBlockInfo(world, pos, false);
return stack.canPlaceOn(world.getTags(), blockworldstate); return stack.canPlaceOn(world.getTags(), blockworldstate);
} }
} }
//From World#mayPlace //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); 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; return false;
} }
//Check if double slab //Check if double slab
if (placer != null && doesBecomeDoubleSlab(((EntityPlayer) placer), pos, sidePlacedOn)) { if (placer != null && doesBecomeDoubleSlab(((PlayerEntity) placer), pos, sidePlacedOn)) {
return true; return true;
} }
@@ -265,13 +261,14 @@ public class SurvivalHelper {
return false; 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; return true;
} }
//Check quickreplace //Check quickreplace
if (placer instanceof EntityPlayer && ModifierSettingsManager.getModifierSettings(((EntityPlayer) placer)).doQuickReplace()) { if (placer instanceof PlayerEntity && ModifierSettingsManager.getModifierSettings(((PlayerEntity) placer)).doQuickReplace()) {
return true; return true;
} }
@@ -282,8 +279,8 @@ public class SurvivalHelper {
//Can break using held tool? (or in creative) //Can break using held tool? (or in creative)
public static boolean canBreak(World world, EntityPlayer player, BlockPos pos) { public static boolean canBreak(World world, PlayerEntity player, BlockPos pos) {
IBlockState blockState = world.getBlockState(pos); BlockState blockState = world.getBlockState(pos);
if (!world.getFluidState(pos).isEmpty()) return false; if (!world.getFluidState(pos).isEmpty()) return false;
if (player.isCreative()) return true; if (player.isCreative()) return true;
@@ -292,9 +289,9 @@ public class SurvivalHelper {
} }
//From ForgeHooks#canHarvestBlock //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 //Dont break bedrock
if (state.getBlockHardness(world, pos) < 0) { if (state.getBlockHardness(world, pos) < 0) {
@@ -324,15 +321,15 @@ public class SurvivalHelper {
return toolLevel >= block.getHarvestLevel(state); return toolLevel >= block.getHarvestLevel(state);
} }
public static boolean doesBecomeDoubleSlab(EntityPlayer player, BlockPos pos, EnumFacing facing) { public static boolean doesBecomeDoubleSlab(PlayerEntity player, BlockPos pos, Direction facing) {
IBlockState placedBlockState = player.world.getBlockState(pos); BlockState placedBlockState = player.world.getBlockState(pos);
ItemStack itemstack = player.getHeldItem(EnumHand.MAIN_HAND); ItemStack itemstack = player.getHeldItem(Hand.MAIN_HAND);
if (CompatHelper.isItemBlockProxy(itemstack)) if (CompatHelper.isItemBlockProxy(itemstack))
itemstack = CompatHelper.getItemBlockFromStack(itemstack); itemstack = CompatHelper.getItemBlockFromStack(itemstack);
if (itemstack.isEmpty() || !(itemstack.getItem() instanceof ItemBlock) || !(((ItemBlock) itemstack.getItem()).getBlock() instanceof BlockSlab)) return false; if (itemstack.isEmpty() || !(itemstack.getItem() instanceof BlockItem) || !(((BlockItem) itemstack.getItem()).getBlock() instanceof SlabBlock)) return false;
BlockSlab heldSlab = (BlockSlab) ((ItemBlock) itemstack.getItem()).getBlock(); SlabBlock heldSlab = (SlabBlock) ((BlockItem) itemstack.getItem()).getBlock();
if (placedBlockState.getBlock() == heldSlab) { if (placedBlockState.getBlock() == heldSlab) {
//TODO 1.13 //TODO 1.13

View File

@@ -1,20 +1,20 @@
package nl.requios.effortlessbuilding.item; package nl.requios.effortlessbuilding.item;
import net.minecraft.block.Block; 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.client.util.ITooltipFlag;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.item.*; import net.minecraft.item.*;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ActionResult; import net.minecraft.util.*;
import net.minecraft.util.EnumActionResult; import net.minecraft.util.ActionResultType;
import net.minecraft.util.EnumFacing; import net.minecraft.util.Hand;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.ITextComponent; 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.TextFormatting;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.common.capabilities.ICapabilityProvider;
@@ -26,7 +26,6 @@ import nl.requios.effortlessbuilding.buildmode.BuildModes;
import nl.requios.effortlessbuilding.buildmode.ModeSettingsManager; import nl.requios.effortlessbuilding.buildmode.ModeSettingsManager;
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager; import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
import nl.requios.effortlessbuilding.capability.ItemHandlerCapabilityProvider; import nl.requios.effortlessbuilding.capability.ItemHandlerCapabilityProvider;
import nl.requios.effortlessbuilding.gui.RandomizerBagContainer;
import nl.requios.effortlessbuilding.gui.RandomizerBagGuiHandler; import nl.requios.effortlessbuilding.gui.RandomizerBagGuiHandler;
import nl.requios.effortlessbuilding.helper.SurvivalHelper; import nl.requios.effortlessbuilding.helper.SurvivalHelper;
@@ -49,39 +48,40 @@ public class ItemRandomizerBag extends Item {
} }
@Override @Override
public EnumActionResult onItemUse(ItemUseContext ctx) { public ActionResultType onItemUse(ItemUseContext ctx) {
EntityPlayer player = ctx.getPlayer(); PlayerEntity player = ctx.getPlayer();
World world = ctx.getWorld(); World world = ctx.getWorld();
BlockPos pos = ctx.getPos(); BlockPos pos = ctx.getPos();
EnumFacing facing = ctx.getFace(); Direction facing = ctx.getFace();
ItemStack item = ctx.getItem(); ItemStack item = ctx.getItem();
Vec3d hitVec = ctx.getHitVec();
if (player == null) return EnumActionResult.FAIL; if (player == null) return ActionResultType.FAIL;
if (ctx.isPlacerSneaking()) { if (ctx.isPlacerSneaking()) {
if (world.isRemote) return EnumActionResult.SUCCESS; if (world.isRemote) return ActionResultType.SUCCESS;
//Open inventory //Open inventory
NetworkHooks.openGui((EntityPlayerMP) player, new RandomizerBagGuiHandler()); NetworkHooks.openGui((ServerPlayerEntity) player, new RandomizerBagGuiHandler());
} else { } else {
if (world.isRemote) return EnumActionResult.SUCCESS; if (world.isRemote) return ActionResultType.SUCCESS;
//Only place manually if in normal vanilla mode //Only place manually if in normal vanilla mode
BuildModes.BuildModeEnum buildMode = ModeSettingsManager.getModeSettings(player).getBuildMode(); BuildModes.BuildModeEnum buildMode = ModeSettingsManager.getModeSettings(player).getBuildMode();
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player); ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
if (buildMode != BuildModes.BuildModeEnum.NORMAL || modifierSettings.doQuickReplace()) { if (buildMode != BuildModes.BuildModeEnum.NORMAL || modifierSettings.doQuickReplace()) {
return EnumActionResult.FAIL; return ActionResultType.FAIL;
} }
//Use item //Use item
//Get bag inventory //Get bag inventory
//TODO offhand support //TODO offhand support
ItemStack bag = player.getHeldItem(EnumHand.MAIN_HAND); ItemStack bag = player.getHeldItem(Hand.MAIN_HAND);
IItemHandler bagInventory = getBagInventory(bag); IItemHandler bagInventory = getBagInventory(bag);
if (bagInventory == null) if (bagInventory == null)
return EnumActionResult.FAIL; return ActionResultType.FAIL;
ItemStack toPlace = pickRandomStack(bagInventory); ItemStack toPlace = pickRandomStack(bagInventory);
if (toPlace.isEmpty()) return EnumActionResult.FAIL; if (toPlace.isEmpty()) return ActionResultType.FAIL;
//Previously: use onItemUse to place block (no synergy) //Previously: use onItemUse to place block (no synergy)
//bag.setItemDamage(toPlace.getMetadata()); //bag.setItemDamage(toPlace.getMetadata());
@@ -92,10 +92,10 @@ public class ItemRandomizerBag extends Item {
pos = pos.offset(facing); pos = pos.offset(facing);
} }
BlockItemUseContext blockItemUseContext = new BlockItemUseContext(world, player, item, pos, facing, ctx.getHitX(), ctx.getHitY(), ctx.getHitZ()); BlockItemUseContext blockItemUseContext = new BlockItemUseContext(new ItemUseContext(player, Hand.MAIN_HAND, new BlockRayTraceResult(hitVec, facing, pos, false)));
IBlockState blockState = Block.getBlockFromItem(toPlace.getItem()).getStateForPlacement(blockItemUseContext); 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 //Synergy
//Works without calling //Works without calling
@@ -104,30 +104,30 @@ public class ItemRandomizerBag extends Item {
// Mirror.onBlockPlaced(placeEvent); // Mirror.onBlockPlaced(placeEvent);
// Array.onBlockPlaced(placeEvent); // Array.onBlockPlaced(placeEvent);
} }
return EnumActionResult.SUCCESS; return ActionResultType.SUCCESS;
} }
@Override @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); ItemStack bag = player.getHeldItem(hand);
if (player.isSneaking()) { if (player.isSneaking()) {
if (world.isRemote) return new ActionResult<>(EnumActionResult.SUCCESS, bag); if (world.isRemote) return new ActionResult<>(ActionResultType.SUCCESS, bag);
//Open inventory //Open inventory
NetworkHooks.openGui((EntityPlayerMP) player, new RandomizerBagGuiHandler()); NetworkHooks.openGui((ServerPlayerEntity) player, new RandomizerBagGuiHandler());
} else { } else {
//Use item //Use item
//Get bag inventory //Get bag inventory
IItemHandler bagInventory = getBagInventory(bag); IItemHandler bagInventory = getBagInventory(bag);
if (bagInventory == null) if (bagInventory == null)
return new ActionResult<>(EnumActionResult.FAIL, bag); return new ActionResult<>(ActionResultType.FAIL, bag);
ItemStack toUse = pickRandomStack(bagInventory); 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 toUse.useItemRightClick(world, player, hand);
} }
return new ActionResult<>(EnumActionResult.PASS, bag); return new ActionResult<>(ActionResultType.PASS, bag);
} }
/** /**
@@ -192,14 +192,14 @@ public class ItemRandomizerBag extends Item {
@Nullable @Nullable
@Override @Override
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) { public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundNBT nbt) {
return new ItemHandlerCapabilityProvider(); return new ItemHandlerCapabilityProvider();
} }
@Override @Override
public void addInformation(ItemStack stack, @Nullable World world, List<ITextComponent> tooltip, ITooltipFlag flag) { 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 StringTextComponent(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 + "Sneak + rightclick" + TextFormatting.GRAY + " to open inventory"));
} }
@Override @Override

View File

@@ -1,13 +1,13 @@
package nl.requios.effortlessbuilding.item; package nl.requios.effortlessbuilding.item;
import net.minecraft.client.util.ITooltipFlag; 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.Item;
import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.*; import net.minecraft.util.*;
import net.minecraft.util.text.ITextComponent; 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.TextFormatting;
import net.minecraft.world.World; import net.minecraft.world.World;
import nl.requios.effortlessbuilding.BuildConfig; import nl.requios.effortlessbuilding.BuildConfig;
@@ -26,11 +26,11 @@ public class ItemReachUpgrade1 extends Item {
} }
@Override @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 (player.isCreative()) {
if (world.isRemote) EffortlessBuilding.log(player, "Reach upgrades are not necessary in creative."); 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."); 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); 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")); SoundEvent soundEvent = new SoundEvent(new ResourceLocation("item.armor.equip_leather"));
player.playSound(soundEvent, 1f, 1f); player.playSound(soundEvent, 1f, 1f);
} }
return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(hand)); return new ActionResult<>(ActionResultType.PASS, player.getHeldItem(hand));
} }
@Override @Override
public void addInformation(ItemStack stack, @Nullable World world, List<ITextComponent> tooltip, ITooltipFlag flag) { 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 @Override

View File

@@ -1,13 +1,13 @@
package nl.requios.effortlessbuilding.item; package nl.requios.effortlessbuilding.item;
import net.minecraft.client.util.ITooltipFlag; 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.Item;
import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.*; import net.minecraft.util.*;
import net.minecraft.util.text.ITextComponent; 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.TextFormatting;
import net.minecraft.world.World; import net.minecraft.world.World;
import nl.requios.effortlessbuilding.BuildConfig; import nl.requios.effortlessbuilding.BuildConfig;
@@ -26,11 +26,11 @@ public class ItemReachUpgrade2 extends Item {
} }
@Override @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 (player.isCreative()) {
if (world.isRemote) EffortlessBuilding.log(player, "Reach upgrades are not necessary in creative."); 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."); 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); 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")); SoundEvent soundEvent = new SoundEvent(new ResourceLocation("item.armor.equip_leather"));
player.playSound(soundEvent, 1f, 1f); player.playSound(soundEvent, 1f, 1f);
} }
return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(hand)); return new ActionResult<>(ActionResultType.PASS, player.getHeldItem(hand));
} }
@Override @Override
public void addInformation(ItemStack stack, @Nullable World world, List<ITextComponent> tooltip, ITooltipFlag flag) { 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 StringTextComponent(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 + "Previous upgrades need to be consumed first"));
} }
@Override @Override

View File

@@ -1,13 +1,13 @@
package nl.requios.effortlessbuilding.item; package nl.requios.effortlessbuilding.item;
import net.minecraft.client.util.ITooltipFlag; 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.Item;
import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.*; import net.minecraft.util.*;
import net.minecraft.util.text.ITextComponent; 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.TextFormatting;
import net.minecraft.world.World; import net.minecraft.world.World;
import nl.requios.effortlessbuilding.BuildConfig; import nl.requios.effortlessbuilding.BuildConfig;
@@ -26,11 +26,11 @@ public class ItemReachUpgrade3 extends Item {
} }
@Override @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 (player.isCreative()) {
if (world.isRemote) EffortlessBuilding.log(player, "Reach upgrades are not necessary in creative."); 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."); 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); 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")); SoundEvent soundEvent = new SoundEvent(new ResourceLocation("item.armor.equip_leather"));
player.playSound(soundEvent, 1f, 1f); player.playSound(soundEvent, 1f, 1f);
} }
return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(hand)); return new ActionResult<>(ActionResultType.PASS, player.getHeldItem(hand));
} }
@Override @Override
public void addInformation(ItemStack stack, @Nullable World world, List<ITextComponent> tooltip, ITooltipFlag flag) { 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 StringTextComponent(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 + "Previous upgrades need to be consumed first"));
} }
@Override @Override

View File

@@ -1,8 +1,8 @@
package nl.requios.effortlessbuilding.network; package nl.requios.effortlessbuilding.network;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.PacketBuffer;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
@@ -20,16 +20,16 @@ import java.util.function.Supplier;
*/ */
public class AddUndoMessage { public class AddUndoMessage {
private BlockPos coordinate; private BlockPos coordinate;
private IBlockState previousBlockState; private BlockState previousBlockState;
private IBlockState newBlockState; private BlockState newBlockState;
public AddUndoMessage() { public AddUndoMessage() {
coordinate = BlockPos.ORIGIN; coordinate = BlockPos.ZERO;
previousBlockState = null; previousBlockState = null;
newBlockState = null; newBlockState = null;
} }
public AddUndoMessage(BlockPos coordinate, IBlockState previousBlockState, IBlockState newBlockState) { public AddUndoMessage(BlockPos coordinate, BlockState previousBlockState, BlockState newBlockState) {
this.coordinate = coordinate; this.coordinate = coordinate;
this.previousBlockState = previousBlockState; this.previousBlockState = previousBlockState;
this.newBlockState = newBlockState; this.newBlockState = newBlockState;
@@ -39,11 +39,11 @@ public class AddUndoMessage {
return coordinate; return coordinate;
} }
public IBlockState getPreviousBlockState() { public BlockState getPreviousBlockState() {
return previousBlockState; return previousBlockState;
} }
public IBlockState getNewBlockState() { public BlockState getNewBlockState() {
return newBlockState; return newBlockState;
} }
@@ -57,8 +57,8 @@ public class AddUndoMessage {
public static AddUndoMessage decode(PacketBuffer buf) { public static AddUndoMessage decode(PacketBuffer buf) {
BlockPos coordinate = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt()); BlockPos coordinate = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt());
IBlockState previousBlockState = Block.getStateById(buf.readInt()); BlockState previousBlockState = Block.getStateById(buf.readInt());
IBlockState newBlockState = Block.getStateById(buf.readInt()); BlockState newBlockState = Block.getStateById(buf.readInt());
return new AddUndoMessage(coordinate, previousBlockState, newBlockState); return new AddUndoMessage(coordinate, previousBlockState, newBlockState);
} }
@@ -72,12 +72,12 @@ public class AddUndoMessage {
if (ctx.get().getDirection().getReceptionSide() == LogicalSide.CLIENT) { if (ctx.get().getDirection().getReceptionSide() == LogicalSide.CLIENT) {
//Received clientside //Received clientside
EntityPlayer player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx); PlayerEntity player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx);
//Add to undo stack clientside //Add to undo stack clientside
UndoRedo.addUndo(ctx.get().getSender(), new BlockSet( UndoRedo.addUndo(ctx.get().getSender(), new BlockSet(
new ArrayList<BlockPos>() {{add(message.getCoordinate());}}, new ArrayList<BlockPos>() {{add(message.getCoordinate());}},
new ArrayList<IBlockState>() {{add(message.getPreviousBlockState());}}, new ArrayList<BlockState>() {{add(message.getPreviousBlockState());}},
new ArrayList<IBlockState>() {{add(message.getNewBlockState());}}, new ArrayList<BlockState>() {{add(message.getNewBlockState());}},
new Vec3d(0,0,0), new Vec3d(0,0,0),
message.getCoordinate(), message.getCoordinate())); message.getCoordinate(), message.getCoordinate()));
} }

View File

@@ -1,8 +1,9 @@
package nl.requios.effortlessbuilding.network; package nl.requios.effortlessbuilding.network;
import net.minecraft.network.PacketBuffer; 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.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraftforge.fml.LogicalSide; import net.minecraftforge.fml.LogicalSide;
@@ -19,24 +20,24 @@ public class BlockBrokenMessage {
private boolean blockHit; private boolean blockHit;
private BlockPos blockPos; private BlockPos blockPos;
private EnumFacing sideHit; private Direction sideHit;
private Vec3d hitVec; private Vec3d hitVec;
public BlockBrokenMessage() { public BlockBrokenMessage() {
this.blockHit = false; this.blockHit = false;
this.blockPos = BlockPos.ORIGIN; this.blockPos = BlockPos.ZERO;
this.sideHit = EnumFacing.UP; this.sideHit = Direction.UP;
this.hitVec = new Vec3d(0, 0, 0); this.hitVec = new Vec3d(0, 0, 0);
} }
public BlockBrokenMessage(RayTraceResult result) { public BlockBrokenMessage(BlockRayTraceResult result) {
this.blockHit = result.type == RayTraceResult.Type.BLOCK; this.blockHit = result.getType() == RayTraceResult.Type.BLOCK;
this.blockPos = result.getBlockPos(); this.blockPos = result.getPos();
this.sideHit = result.sideHit; this.sideHit = result.getFace();
this.hitVec = result.hitVec; 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.blockHit = blockHit;
this.blockPos = blockPos; this.blockPos = blockPos;
this.sideHit = sideHit; this.sideHit = sideHit;
@@ -51,7 +52,7 @@ public class BlockBrokenMessage {
return blockPos; return blockPos;
} }
public EnumFacing getSideHit() { public Direction getSideHit() {
return sideHit; return sideHit;
} }
@@ -73,7 +74,7 @@ public class BlockBrokenMessage {
public static BlockBrokenMessage decode(PacketBuffer buf) { public static BlockBrokenMessage decode(PacketBuffer buf) {
boolean blockHit = buf.readBoolean(); boolean blockHit = buf.readBoolean();
BlockPos blockPos = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt()); 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()); Vec3d hitVec = new Vec3d(buf.readDouble(), buf.readDouble(), buf.readDouble());
return new BlockBrokenMessage(blockHit, blockPos, sideHit, hitVec); return new BlockBrokenMessage(blockHit, blockPos, sideHit, hitVec);
} }

View File

@@ -1,7 +1,8 @@
package nl.requios.effortlessbuilding.network; 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.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.PacketBuffer;
@@ -21,27 +22,27 @@ public class BlockPlacedMessage {
private boolean blockHit; private boolean blockHit;
private BlockPos blockPos; private BlockPos blockPos;
private EnumFacing sideHit; private Direction sideHit;
private Vec3d hitVec; private Vec3d hitVec;
private boolean placeStartPos; //prevent double placing in normal mode private boolean placeStartPos; //prevent double placing in normal mode
public BlockPlacedMessage() { public BlockPlacedMessage() {
this.blockHit = false; this.blockHit = false;
this.blockPos = BlockPos.ORIGIN; this.blockPos = BlockPos.ZERO;
this.sideHit = EnumFacing.UP; this.sideHit = Direction.UP;
this.hitVec = new Vec3d(0, 0, 0); this.hitVec = new Vec3d(0, 0, 0);
this.placeStartPos = true; this.placeStartPos = true;
} }
public BlockPlacedMessage(RayTraceResult result, boolean placeStartPos) { public BlockPlacedMessage(BlockRayTraceResult result, boolean placeStartPos) {
this.blockHit = result.type == RayTraceResult.Type.BLOCK; this.blockHit = result.getType() == RayTraceResult.Type.BLOCK;
this.blockPos = result.getBlockPos(); this.blockPos = result.getPos();
this.sideHit = result.sideHit; this.sideHit = result.getFace();
this.hitVec = result.hitVec; this.hitVec = result.getHitVec();
this.placeStartPos = placeStartPos; 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.blockHit = blockHit;
this.blockPos = blockPos; this.blockPos = blockPos;
this.sideHit = sideHit; this.sideHit = sideHit;
@@ -57,7 +58,7 @@ public class BlockPlacedMessage {
return blockPos; return blockPos;
} }
public EnumFacing getSideHit() { public Direction getSideHit() {
return sideHit; return sideHit;
} }
@@ -84,7 +85,7 @@ public class BlockPlacedMessage {
public static BlockPlacedMessage decode(PacketBuffer buf) { public static BlockPlacedMessage decode(PacketBuffer buf) {
boolean blockHit = buf.readBoolean(); boolean blockHit = buf.readBoolean();
BlockPos blockPos = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt()); 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()); Vec3d hitVec = new Vec3d(buf.readDouble(), buf.readDouble(), buf.readDouble());
boolean placeStartPos = buf.readBoolean(); boolean placeStartPos = buf.readBoolean();
return new BlockPlacedMessage(blockHit, blockPos, sideHit, hitVec, placeStartPos); return new BlockPlacedMessage(blockHit, blockPos, sideHit, hitVec, placeStartPos);

View File

@@ -1,6 +1,6 @@
package nl.requios.effortlessbuilding.network; 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.network.PacketBuffer;
import net.minecraftforge.fml.network.NetworkEvent; import net.minecraftforge.fml.network.NetworkEvent;
import nl.requios.effortlessbuilding.EffortlessBuilding; import nl.requios.effortlessbuilding.EffortlessBuilding;
@@ -27,7 +27,7 @@ public class CancelModeMessage {
ctx.get().enqueueWork(() -> { ctx.get().enqueueWork(() -> {
EffortlessBuilding.log("CancelModeMessage"); EffortlessBuilding.log("CancelModeMessage");
EntityPlayer player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx); PlayerEntity player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx);
BuildModes.initializeMode(player); BuildModes.initializeMode(player);
}); });

View File

@@ -1,6 +1,6 @@
package nl.requios.effortlessbuilding.network; 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.network.PacketBuffer;
import net.minecraftforge.fml.LogicalSide; import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.network.NetworkEvent; import net.minecraftforge.fml.network.NetworkEvent;
@@ -34,7 +34,7 @@ public class ClearUndoMessage {
if (ctx.get().getDirection().getReceptionSide() == LogicalSide.CLIENT) { if (ctx.get().getDirection().getReceptionSide() == LogicalSide.CLIENT) {
//Received clientside //Received clientside
EntityPlayer player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx); PlayerEntity player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx);
//Add to undo stack clientside //Add to undo stack clientside
UndoRedo.clear(player); UndoRedo.clear(player);

View File

@@ -1,6 +1,6 @@
package nl.requios.effortlessbuilding.network; 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.network.PacketBuffer;
import net.minecraftforge.fml.network.NetworkEvent; import net.minecraftforge.fml.network.NetworkEvent;
import nl.requios.effortlessbuilding.EffortlessBuilding; import nl.requios.effortlessbuilding.EffortlessBuilding;
@@ -38,7 +38,7 @@ public class ModeActionMessage {
ctx.get().enqueueWork(() -> { ctx.get().enqueueWork(() -> {
EffortlessBuilding.log("ModeActionMessage"); EffortlessBuilding.log("ModeActionMessage");
EntityPlayer player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx); PlayerEntity player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx);
ModeOptions.performAction(player, message.action); ModeOptions.performAction(player, message.action);
}); });

View File

@@ -1,9 +1,7 @@
package nl.requios.effortlessbuilding.network; package nl.requios.effortlessbuilding.network;
import io.netty.buffer.ByteBuf; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.PacketBuffer;
import net.minecraft.util.IThreadListener;
import net.minecraftforge.fml.network.NetworkEvent; import net.minecraftforge.fml.network.NetworkEvent;
import nl.requios.effortlessbuilding.EffortlessBuilding; import nl.requios.effortlessbuilding.EffortlessBuilding;
import nl.requios.effortlessbuilding.buildmode.BuildModes; import nl.requios.effortlessbuilding.buildmode.BuildModes;
@@ -43,7 +41,7 @@ public class ModeSettingsMessage {
ctx.get().enqueueWork(() -> { ctx.get().enqueueWork(() -> {
EffortlessBuilding.log("ModeSettingsMessage"); EffortlessBuilding.log("ModeSettingsMessage");
EntityPlayer player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx); PlayerEntity player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx);
// Sanitize // Sanitize
ModeSettingsManager.sanitize(message.modeSettings, player); ModeSettingsManager.sanitize(message.modeSettings, player);

View File

@@ -1,6 +1,6 @@
package nl.requios.effortlessbuilding.network; 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.network.PacketBuffer;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
@@ -131,7 +131,7 @@ public class ModifierSettingsMessage {
ctx.get().enqueueWork(() -> { ctx.get().enqueueWork(() -> {
EffortlessBuilding.log("ModifierSettingsMessage"); EffortlessBuilding.log("ModifierSettingsMessage");
EntityPlayer player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx); PlayerEntity player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx);
// Sanitize // Sanitize
ModifierSettingsManager.sanitize(message.modifierSettings, player); ModifierSettingsManager.sanitize(message.modifierSettings, player);

View File

@@ -1,19 +1,12 @@
package nl.requios.effortlessbuilding.network; package nl.requios.effortlessbuilding.network;
import net.minecraft.block.Block; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.PacketBuffer; 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.LogicalSide;
import net.minecraftforge.fml.network.NetworkEvent; import net.minecraftforge.fml.network.NetworkEvent;
import nl.requios.effortlessbuilding.EffortlessBuilding; import nl.requios.effortlessbuilding.EffortlessBuilding;
import nl.requios.effortlessbuilding.buildmodifier.BlockSet;
import nl.requios.effortlessbuilding.buildmodifier.UndoRedo;
import nl.requios.effortlessbuilding.proxy.ClientProxy; import nl.requios.effortlessbuilding.proxy.ClientProxy;
import java.util.ArrayList;
import java.util.function.Supplier; import java.util.function.Supplier;
/*** /***
@@ -54,7 +47,7 @@ public class RequestLookAtMessage {
if (ctx.get().getDirection().getReceptionSide() == LogicalSide.CLIENT) { if (ctx.get().getDirection().getReceptionSide() == LogicalSide.CLIENT) {
//Received clientside //Received clientside
//Send back your info //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 //Prevent double placing in normal mode with placeStartPos false
//Unless QuickReplace is on, then we do need to place start pos. //Unless QuickReplace is on, then we do need to place start pos.

View File

@@ -1,39 +1,36 @@
package nl.requios.effortlessbuilding.proxy; package nl.requios.effortlessbuilding.proxy;
import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType; 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.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.texture.AtlasTexture;
import net.minecraft.client.resources.I18n; import net.minecraft.client.resources.I18n;
import net.minecraft.client.settings.KeyBinding; import net.minecraft.client.settings.KeyBinding;
import net.minecraft.client.util.InputMappings; import net.minecraft.client.util.InputMappings;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemBlock; import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHand; import net.minecraft.util.Hand;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.*;
import net.minecraft.util.math.RayTraceFluidMode;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.GuiOpenEvent; import net.minecraftforge.client.event.GuiOpenEvent;
import net.minecraftforge.client.event.InputEvent; import net.minecraftforge.client.event.InputEvent;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.client.settings.KeyConflictContext; import net.minecraftforge.client.settings.KeyConflictContext;
import net.minecraftforge.client.settings.KeyModifier; import net.minecraftforge.client.settings.KeyModifier;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.LogicalSide; import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.Mod; 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.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.network.NetworkEvent; import net.minecraftforge.fml.network.NetworkEvent;
@@ -58,8 +55,8 @@ import java.util.function.Supplier;
@Mod.EventBusSubscriber(value = {Dist.CLIENT}) @Mod.EventBusSubscriber(value = {Dist.CLIENT})
public class ClientProxy implements IProxy { public class ClientProxy implements IProxy {
public static KeyBinding[] keyBindings; public static KeyBinding[] keyBindings;
public static RayTraceResult previousLookAt; public static BlockRayTraceResult previousLookAt;
public static RayTraceResult currentLookAt; public static BlockRayTraceResult currentLookAt;
private static int placeCooldown = 0; private static int placeCooldown = 0;
private static int breakCooldown = 0; private static int breakCooldown = 0;
private static boolean shadersInitialized = false; private static boolean shadersInitialized = false;
@@ -104,7 +101,7 @@ public class ClientProxy implements IProxy {
} }
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()); return (ctx.get().getDirection().getReceptionSide() == LogicalSide.CLIENT ? Minecraft.getInstance().player : ctx.get().getSender());
} }
@@ -118,7 +115,7 @@ public class ClientProxy implements IProxy {
@SubscribeEvent @SubscribeEvent
public static void onTextureStitch(final TextureStitchEvent.Pre event) { public static void onTextureStitch(final TextureStitchEvent.Pre event) {
//register icon textures //register icon textures
final TextureMap map = event.getMap(); final AtlasTexture map = event.getMap();
for ( final BuildModes.BuildModeEnum mode : BuildModes.BuildModeEnum.values() ) for ( final BuildModes.BuildModeEnum mode : BuildModes.BuildModeEnum.values() )
{ {
@@ -160,12 +157,12 @@ public class ClientProxy implements IProxy {
return; return;
} }
if (objectMouseOver.type == RayTraceResult.Type.BLOCK) { if (objectMouseOver.getType() == RayTraceResult.Type.BLOCK) {
if (currentLookAt.type != RayTraceResult.Type.BLOCK) { if (currentLookAt.getType() != RayTraceResult.Type.BLOCK) {
currentLookAt = objectMouseOver; currentLookAt = objectMouseOver;
previousLookAt = objectMouseOver; previousLookAt = objectMouseOver;
} else { } else {
if (currentLookAt.getBlockPos() != objectMouseOver.getBlockPos()) { if (currentLookAt.getPos() != objectMouseOver.getPos()) {
previousLookAt = currentLookAt; previousLookAt = currentLookAt;
currentLookAt = objectMouseOver; currentLookAt = objectMouseOver;
} }
@@ -173,8 +170,8 @@ public class ClientProxy implements IProxy {
} }
} else if (event.phase == TickEvent.Phase.END){ } else if (event.phase == TickEvent.Phase.END){
GuiScreen gui = Minecraft.getInstance().currentScreen; Screen gui = Minecraft.getInstance().currentScreen;
if(gui == null || !gui.doesGuiPauseGame()) { if(gui == null || !gui.isPauseScreen()) {
ticksInGame++; ticksInGame++;
} }
@@ -189,7 +186,7 @@ public class ClientProxy implements IProxy {
private static void onMouseInput() { private static void onMouseInput() {
Minecraft mc = Minecraft.getInstance(); Minecraft mc = Minecraft.getInstance();
EntityPlayerSP player = mc.player; ClientPlayerEntity player = mc.player;
if (player == null) return; if (player == null) return;
BuildModes.BuildModeEnum buildMode = ModeSettingsManager.getModeSettings(player).getBuildMode(); BuildModes.BuildModeEnum buildMode = ModeSettingsManager.getModeSettings(player).getBuildMode();
@@ -206,28 +203,28 @@ public class ClientProxy implements IProxy {
if (placeCooldown <= 0) { if (placeCooldown <= 0) {
placeCooldown = 4; placeCooldown = 4;
ItemStack currentItemStack = player.getHeldItem(EnumHand.MAIN_HAND); ItemStack currentItemStack = player.getHeldItem(Hand.MAIN_HAND);
if (currentItemStack.getItem() instanceof ItemBlock || if (currentItemStack.getItem() instanceof BlockItem ||
(CompatHelper.isItemBlockProxy(currentItemStack) && !player.isSneaking())) { (CompatHelper.isItemBlockProxy(currentItemStack) && !player.isSneaking())) {
ItemStack itemStack = CompatHelper.getItemBlockFromStack(currentItemStack); ItemStack itemStack = CompatHelper.getItemBlockFromStack(currentItemStack);
//find position in distance //find position in distance
RayTraceResult lookingAt = getLookingAt(player); BlockRayTraceResult lookingAt = getLookingAt(player);
BuildModes.onBlockPlacedMessage(player, lookingAt == null ? new BlockPlacedMessage() : new BlockPlacedMessage(lookingAt, true)); BuildModes.onBlockPlacedMessage(player, lookingAt == null ? new BlockPlacedMessage() : new BlockPlacedMessage(lookingAt, true));
PacketHandler.INSTANCE.sendToServer(lookingAt == null ? new BlockPlacedMessage() : new BlockPlacedMessage(lookingAt, true)); PacketHandler.INSTANCE.sendToServer(lookingAt == null ? new BlockPlacedMessage() : new BlockPlacedMessage(lookingAt, true));
//play sound if further than normal //play sound if further than normal
if (lookingAt != null && lookingAt.type == RayTraceResult.Type.BLOCK && if (lookingAt != null && lookingAt.getType() == RayTraceResult.Type.BLOCK &&
(lookingAt.hitVec.subtract(player.getEyePosition(1f))).lengthSquared() > 25f && (lookingAt.getHitVec().subtract(player.getEyePosition(1f))).lengthSquared() > 25f &&
itemStack.getItem() instanceof ItemBlock) { itemStack.getItem() instanceof BlockItem) {
IBlockState state = ((ItemBlock) itemStack.getItem()).getBlock().getDefaultState(); BlockState state = ((BlockItem) itemStack.getItem()).getBlock().getDefaultState();
BlockPos blockPos = lookingAt.getBlockPos(); BlockPos blockPos = lookingAt.getPos();
SoundType soundType = state.getBlock().getSoundType(state, player.world, blockPos, player); SoundType soundType = state.getBlock().getSoundType(state, player.world, blockPos, player);
player.world.playSound(player, player.getPosition(), soundType.getPlaceSound(), SoundCategory.BLOCKS, player.world.playSound(player, player.getPosition(), soundType.getPlaceSound(), SoundCategory.BLOCKS,
0.4f, soundType.getPitch() * 1f); 0.4f, soundType.getPitch() * 1f);
player.swingArm(EnumHand.MAIN_HAND); player.swingArm(Hand.MAIN_HAND);
} }
} }
} }
@@ -251,20 +248,20 @@ public class ClientProxy implements IProxy {
// moving it to after buildmodes fixes that, but introduces this bug // moving it to after buildmodes fixes that, but introduces this bug
if (!ReachHelper.canBreakFar(player)) return; if (!ReachHelper.canBreakFar(player)) return;
RayTraceResult lookingAt = getLookingAt(player); BlockRayTraceResult lookingAt = getLookingAt(player);
BuildModes.onBlockBrokenMessage(player, lookingAt == null ? new BlockBrokenMessage() : new BlockBrokenMessage(lookingAt)); BuildModes.onBlockBrokenMessage(player, lookingAt == null ? new BlockBrokenMessage() : new BlockBrokenMessage(lookingAt));
PacketHandler.INSTANCE.sendToServer(lookingAt == null ? new BlockBrokenMessage() : new BlockBrokenMessage(lookingAt)); PacketHandler.INSTANCE.sendToServer(lookingAt == null ? new BlockBrokenMessage() : new BlockBrokenMessage(lookingAt));
//play sound if further than normal //play sound if further than normal
if (lookingAt != null && lookingAt.type == RayTraceResult.Type.BLOCK && if (lookingAt != null && lookingAt.getType() == RayTraceResult.Type.BLOCK &&
(lookingAt.hitVec.subtract(player.getEyePosition(1f))).lengthSquared() > 25f) { (lookingAt.getHitVec().subtract(player.getEyePosition(1f))).lengthSquared() > 25f) {
BlockPos blockPos = lookingAt.getBlockPos(); BlockPos blockPos = lookingAt.getPos();
IBlockState state = player.world.getBlockState(blockPos); BlockState state = player.world.getBlockState(blockPos);
SoundType soundtype = state.getBlock().getSoundType(state, player.world, blockPos, player); SoundType soundtype = state.getBlock().getSoundType(state, player.world, blockPos, player);
player.world.playSound(player, player.getPosition(), soundtype.getBreakSound(), SoundCategory.BLOCKS, player.world.playSound(player, player.getPosition(), soundtype.getBreakSound(), SoundCategory.BLOCKS,
0.4f, soundtype.getPitch() * 1f); 0.4f, soundtype.getPitch() * 1f);
player.swingArm(EnumHand.MAIN_HAND); player.swingArm(Hand.MAIN_HAND);
} }
} }
else if (buildMode == BuildModes.BuildModeEnum.NORMAL_PLUS) { else if (buildMode == BuildModes.BuildModeEnum.NORMAL_PLUS) {
@@ -281,7 +278,7 @@ public class ClientProxy implements IProxy {
@SubscribeEvent(receiveCanceled = true) @SubscribeEvent(receiveCanceled = true)
public static void onKeyPress(InputEvent.KeyInputEvent event) { 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 //Remember to send packet to server if necessary
//Show Modifier Settings GUI //Show Modifier Settings GUI
@@ -349,7 +346,7 @@ public class ClientProxy implements IProxy {
public static void openModifierSettings() { public static void openModifierSettings() {
Minecraft mc = Minecraft.getInstance(); Minecraft mc = Minecraft.getInstance();
EntityPlayerSP player = mc.player; ClientPlayerEntity player = mc.player;
RadialMenu.instance.setVisibility(0f); RadialMenu.instance.setVisibility(0f);
@@ -367,24 +364,25 @@ public class ClientProxy implements IProxy {
@SubscribeEvent @SubscribeEvent
public static void onGuiOpen(GuiOpenEvent event) { public static void onGuiOpen(GuiOpenEvent event) {
EntityPlayer player = Minecraft.getInstance().player; PlayerEntity player = Minecraft.getInstance().player;
if (player != null) { if (player != null) {
BuildModes.initializeMode(player); BuildModes.initializeMode(player);
} }
} }
@Nullable @Nullable
public static RayTraceResult getLookingAt(EntityPlayer player) { public static BlockRayTraceResult getLookingAt(PlayerEntity player) {
// World world = player.world; World world = player.world;
//base distance off of player ability (config) //base distance off of player ability (config)
float raytraceRange = ReachHelper.getPlacementReach(player); float raytraceRange = ReachHelper.getPlacementReach(player);
// Vec3d look = player.getLookVec(); Vec3d look = player.getLookVec();
// Vec3d start = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ); 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); 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 player.rayTrace(raytraceRange, 1f, RayTraceFluidMode.NEVER);
// return world.rayTraceBlocks(start, end, false, false, false); //TODO 1.14 check if correct, make sure it is a blockraytraceresult
return world.rayTraceBlocks(new RayTraceContext(start, end, RayTraceContext.BlockMode.COLLIDER, RayTraceContext.FluidMode.NONE, player));
} }
public static void logTranslate(String key) { public static void logTranslate(String key) {

View File

@@ -1,6 +1,6 @@
package nl.requios.effortlessbuilding.proxy; 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.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.network.NetworkEvent; import net.minecraftforge.fml.network.NetworkEvent;
@@ -12,5 +12,5 @@ public interface IProxy {
void clientSetup(final FMLClientSetupEvent event); void clientSetup(final FMLClientSetupEvent event);
EntityPlayer getPlayerEntityFromContext(Supplier<NetworkEvent.Context> ctx); PlayerEntity getPlayerEntityFromContext(Supplier<NetworkEvent.Context> ctx);
} }

View File

@@ -1,6 +1,6 @@
package nl.requios.effortlessbuilding.proxy; 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.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.network.NetworkEvent; import net.minecraftforge.fml.network.NetworkEvent;
@@ -17,7 +17,7 @@ public class ServerProxy implements IProxy {
@Override @Override
public void clientSetup(FMLClientSetupEvent event) {} public void clientSetup(FMLClientSetupEvent event) {}
public EntityPlayer getPlayerEntityFromContext(Supplier<NetworkEvent.Context> ctx){ public PlayerEntity getPlayerEntityFromContext(Supplier<NetworkEvent.Context> ctx){
return ctx.get().getSender(); return ctx.get().getSender();
} }
} }

View File

@@ -1,21 +1,17 @@
package nl.requios.effortlessbuilding.render; 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.SoundType;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft; 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.BlockRendererDispatcher;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.texture.AtlasTexture;
import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing; import net.minecraft.util.Direction;
import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.*;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; 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.helper.SurvivalHelper;
import nl.requios.effortlessbuilding.item.ItemRandomizerBag; import nl.requios.effortlessbuilding.item.ItemRandomizerBag;
import nl.requios.effortlessbuilding.proxy.ClientProxy; import nl.requios.effortlessbuilding.proxy.ClientProxy;
import org.lwjgl.opengl.ARBMultitexture; import org.lwjgl.opengl.*;
import org.lwjgl.opengl.ARBShaderObjects;
import org.lwjgl.opengl.GL11;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@@ -45,7 +39,7 @@ import java.util.function.Consumer;
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public class BlockPreviewRenderer { public class BlockPreviewRenderer {
private static List<BlockPos> previousCoordinates; private static List<BlockPos> previousCoordinates;
private static List<IBlockState> previousBlockStates; private static List<BlockState> previousBlockStates;
private static List<ItemStack> previousItemStacks; private static List<ItemStack> previousItemStacks;
private static BlockPos previousFirstPos; private static BlockPos previousFirstPos;
private static BlockPos previousSecondPos; private static BlockPos previousSecondPos;
@@ -54,13 +48,13 @@ public class BlockPreviewRenderer {
static class PlacedData { static class PlacedData {
float time; float time;
List<BlockPos> coordinates; List<BlockPos> coordinates;
List<IBlockState> blockStates; List<BlockState> blockStates;
List<ItemStack> itemStacks; List<ItemStack> itemStacks;
BlockPos firstPos; BlockPos firstPos;
BlockPos secondPos; BlockPos secondPos;
boolean breaking; 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) { List<ItemStack> itemStacks, BlockPos firstPos, BlockPos secondPos, boolean breaking) {
this.time = time; this.time = time;
this.coordinates = coordinates; this.coordinates = coordinates;
@@ -77,7 +71,7 @@ public class BlockPreviewRenderer {
private static final int primaryTextureUnit = 0; private static final int primaryTextureUnit = 0;
private static final int secondaryTextureUnit = 2; 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 //Render placed blocks with dissolve effect
//Use fancy shader if config allows, otherwise no dissolve //Use fancy shader if config allows, otherwise no dissolve
@@ -101,26 +95,26 @@ public class BlockPreviewRenderer {
}); });
//Render block previews //Render block previews
RayTraceResult lookingAt = ClientProxy.getLookingAt(player); BlockRayTraceResult lookingAt = ClientProxy.getLookingAt(player);
if (modeSettings.getBuildMode() == BuildModes.BuildModeEnum.NORMAL) lookingAt = Minecraft.getInstance().objectMouseOver; if (modeSettings.getBuildMode() == BuildModes.BuildModeEnum.NORMAL) lookingAt = Minecraft.getInstance().objectMouseOver;
ItemStack mainhand = player.getHeldItemMainhand(); ItemStack mainhand = player.getHeldItemMainhand();
boolean toolInHand = !(!mainhand.isEmpty() && CompatHelper.isItemBlockProxy(mainhand)); boolean toolInHand = !(!mainhand.isEmpty() && CompatHelper.isItemBlockProxy(mainhand));
BlockPos startPos = null; BlockPos startPos = null;
EnumFacing sideHit = null; Direction sideHit = null;
Vec3d hitVec = null; Vec3d hitVec = null;
//Checking for null is necessary! Even in vanilla when looking down ladders it is occasionally null (instead of Type MISS) //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) { if (lookingAt != null && lookingAt.getType() == RayTraceResult.Type.BLOCK) {
startPos = lookingAt.getBlockPos(); startPos = lookingAt.getPos();
//Check if tool (or none) in hand //Check if tool (or none) in hand
//TODO 1.13 replaceable //TODO 1.13 replaceable
boolean replaceable = player.world.getBlockState(startPos).getBlock().getMaterial(player.world.getBlockState(startPos)).isReplaceable(); 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, lookingAt.getFace());
if (!modifierSettings.doQuickReplace() && !toolInHand && !replaceable && !becomesDoubleSlab) { if (!modifierSettings.doQuickReplace() && !toolInHand && !replaceable && !becomesDoubleSlab) {
startPos = startPos.offset(lookingAt.sideHit); startPos = startPos.offset(lookingAt.getFace());
} }
//Get under tall grass and other replaceable blocks //Get under tall grass and other replaceable blocks
@@ -128,8 +122,8 @@ public class BlockPreviewRenderer {
startPos = startPos.down(); startPos = startPos.down();
} }
sideHit = lookingAt.sideHit; sideHit = lookingAt.getFace();
hitVec = lookingAt.hitVec; hitVec = lookingAt.getHitVec();
} }
//Dont render if in normal mode and modifiers are disabled //Dont render if in normal mode and modifiers are disabled
@@ -153,7 +147,7 @@ public class BlockPreviewRenderer {
List<BlockPos> startCoordinates = BuildModes.findCoordinates(player, startPos, breaking || modifierSettings.doQuickReplace()); List<BlockPos> startCoordinates = BuildModes.findCoordinates(player, startPos, breaking || modifierSettings.doQuickReplace());
//Remember first and last point for the shader //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()) { if (!startCoordinates.isEmpty()) {
firstPos = startCoordinates.get(0); firstPos = startCoordinates.get(0);
secondPos = startCoordinates.get(startCoordinates.size() - 1); secondPos = startCoordinates.get(startCoordinates.size() - 1);
@@ -174,7 +168,7 @@ public class BlockPreviewRenderer {
//Get blockstates //Get blockstates
List<ItemStack> itemStacks = new ArrayList<>(); List<ItemStack> itemStacks = new ArrayList<>();
List<IBlockState> blockStates = new ArrayList<>(); List<BlockState> blockStates = new ArrayList<>();
if (breaking) { if (breaking) {
//Find blockstate of world //Find blockstate of world
for (BlockPos coordinate : newCoordinates) { for (BlockPos coordinate : newCoordinates) {
@@ -271,17 +265,17 @@ public class BlockPreviewRenderer {
RenderHandler.beginLines(); RenderHandler.beginLines();
//Draw outlines if tool in hand //Draw outlines if tool in hand
//Find proper raytrace: either normal range or increased range depending on canBreakFar //Find proper raytrace: either normal range or increased range depending on canBreakFar
RayTraceResult objectMouseOver = Minecraft.getInstance().objectMouseOver; BlockRayTraceResult objectMouseOver = Minecraft.getInstance().objectMouseOver;
RayTraceResult breakingRaytrace = ReachHelper.canBreakFar(player) ? lookingAt : objectMouseOver; BlockRayTraceResult breakingRaytrace = ReachHelper.canBreakFar(player) ? lookingAt : objectMouseOver;
if (toolInHand && breakingRaytrace != null && breakingRaytrace.type == RayTraceResult.Type.BLOCK) { if (toolInHand && breakingRaytrace != null && breakingRaytrace.getType() == RayTraceResult.Type.BLOCK) {
List<BlockPos> breakCoordinates = BuildModifiers.findCoordinates(player, breakingRaytrace.getBlockPos()); List<BlockPos> breakCoordinates = BuildModifiers.findCoordinates(player, breakingRaytrace.getPos());
//Only render first outline if further than normal reach //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++) { for (int i = excludeFirst ? 1 : 0; i < breakCoordinates.size(); i++) {
BlockPos coordinate = breakCoordinates.get(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 (!blockState.getBlock().isAir(blockState, player.world, coordinate)) {
if (SurvivalHelper.canBreak(player.world, player, coordinate) || i == 0) { if (SurvivalHelper.canBreak(player.world, player, coordinate) || i == 0) {
VoxelShape collisionShape = blockState.getCollisionShape(player.world, coordinate); VoxelShape collisionShape = blockState.getCollisionShape(player.world, coordinate);
@@ -301,10 +295,10 @@ public class BlockPreviewRenderer {
BuildConfig.visuals.alwaysShowBlockPreview.get(); 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, List<ItemStack> itemStacks, float dissolve, BlockPos firstPos,
BlockPos secondPos, boolean checkCanPlace, boolean red) { BlockPos secondPos, boolean checkCanPlace, boolean red) {
EntityPlayer player = Minecraft.getInstance().player; PlayerEntity player = Minecraft.getInstance().player;
ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player); ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
BlockRendererDispatcher dispatcher = Minecraft.getInstance().getBlockRendererDispatcher(); BlockRendererDispatcher dispatcher = Minecraft.getInstance().getBlockRendererDispatcher();
int blocksValid = 0; int blocksValid = 0;
@@ -313,7 +307,7 @@ public class BlockPreviewRenderer {
for (int i = coordinates.size() - 1; i >= 0; i--) { for (int i = coordinates.size() - 1; i >= 0; i--) {
BlockPos blockPos = coordinates.get(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); ItemStack itemstack = itemStacks.isEmpty() ? ItemStack.EMPTY : itemStacks.get(i);
if (CompatHelper.isItemBlockProxy(itemstack)) if (CompatHelper.isItemBlockProxy(itemstack))
itemstack = CompatHelper.getItemBlockByState(itemstack, blockState); itemstack = CompatHelper.getItemBlockByState(itemstack, blockState);
@@ -321,7 +315,7 @@ public class BlockPreviewRenderer {
//Check if can place //Check if can place
//If check is turned off, check if blockstate is the same (for dissolve effect) //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) 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, ShaderHandler.useShader(ShaderHandler.dissolve, generateShaderCallback(dissolve,
new Vec3d(blockPos), new Vec3d(firstPos), new Vec3d(secondPos), new Vec3d(blockPos), new Vec3d(firstPos), new Vec3d(secondPos),
@@ -337,9 +331,9 @@ public class BlockPreviewRenderer {
onBlocksPlaced(previousCoordinates, previousItemStacks, previousBlockStates, previousFirstPos, previousSecondPos); 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) { BlockPos firstPos, BlockPos secondPos) {
EntityPlayerSP player = Minecraft.getInstance().player; ClientPlayerEntity player = Minecraft.getInstance().player;
ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player); ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
ModeSettings modeSettings = ModeSettingsManager.getModeSettings(player); ModeSettings modeSettings = ModeSettingsManager.getModeSettings(player);
@@ -361,9 +355,9 @@ public class BlockPreviewRenderer {
onBlocksBroken(previousCoordinates, previousItemStacks, previousBlockStates, previousFirstPos, previousSecondPos); 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) { BlockPos firstPos, BlockPos secondPos) {
EntityPlayerSP player = Minecraft.getInstance().player; ClientPlayerEntity player = Minecraft.getInstance().player;
ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player); ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
ModeSettings modeSettings = ModeSettingsManager.getModeSettings(player); ModeSettings modeSettings = ModeSettingsManager.getModeSettings(player);
@@ -397,18 +391,18 @@ public class BlockPreviewRenderer {
int imageUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "image"); int imageUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "image");
int maskUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "mask"); int maskUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "mask");
GlStateManager.enableTexture2D(); GlStateManager.enableTexture();
GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D); GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
//mask //mask
ARBShaderObjects.glUniform1iARB(maskUniform, secondaryTextureUnit); 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()); GL11.glBindTexture(GL11.GL_TEXTURE_2D, mc.getTextureManager().getTexture(ShaderHandler.shaderMaskTextureLocation).getGlTextureId());
//image //image
ARBShaderObjects.glUniform1iARB(imageUniform, primaryTextureUnit); ARBShaderObjects.glUniform1iARB(imageUniform, primaryTextureUnit);
OpenGlHelper.glActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + primaryTextureUnit); glActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + primaryTextureUnit);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, mc.getTextureManager().getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).getGlTextureId()); GL11.glBindTexture(GL11.GL_TEXTURE_2D, mc.getTextureManager().getTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE).getGlTextureId());
//blockpos //blockpos
ARBShaderObjects.glUniform3fARB(blockposUniform, (float) blockpos.x, (float) blockpos.y, (float) blockpos.z); ARBShaderObjects.glUniform3fARB(blockposUniform, (float) blockpos.x, (float) blockpos.y, (float) blockpos.z);
@@ -424,7 +418,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) -> { Collections.sort(coordinates, (lhs, rhs) -> {
// -1 - less than, 1 - greater than, 0 - equal // -1 - less than, 1 - greater than, 0 - equal

View File

@@ -1,26 +1,22 @@
package nl.requios.effortlessbuilding.render; 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.Minecraft;
import net.minecraft.client.audio.SimpleSound; 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.BlockRendererDispatcher;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.client.resources.I18n; import net.minecraft.client.resources.I18n;
import net.minecraft.client.settings.KeyBinding; import net.minecraft.client.settings.KeyBinding;
import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.particles.IParticleData;
import net.minecraft.util.SoundCategory; 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.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.shapes.VoxelShape; 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.api.distmarker.Dist;
import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderWorldLastEvent; 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.EffortlessBuilding;
import nl.requios.effortlessbuilding.buildmode.ModeOptions; import nl.requios.effortlessbuilding.buildmode.ModeOptions;
import nl.requios.effortlessbuilding.buildmode.ModeSettingsManager; import nl.requios.effortlessbuilding.buildmode.ModeSettingsManager;
import nl.requios.effortlessbuilding.buildmodifier.BuildModifiers;
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager; import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
import nl.requios.effortlessbuilding.gui.buildmode.RadialMenu; import nl.requios.effortlessbuilding.gui.buildmode.RadialMenu;
import nl.requios.effortlessbuilding.helper.ReachHelper; import nl.requios.effortlessbuilding.helper.ReachHelper;
import nl.requios.effortlessbuilding.helper.SurvivalHelper;
import nl.requios.effortlessbuilding.network.ModeActionMessage; import nl.requios.effortlessbuilding.network.ModeActionMessage;
import nl.requios.effortlessbuilding.network.ModeSettingsMessage; import nl.requios.effortlessbuilding.network.ModeSettingsMessage;
import nl.requios.effortlessbuilding.network.PacketHandler; 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.GL11;
import org.lwjgl.opengl.GL14; import org.lwjgl.opengl.GL14;
import javax.annotation.Nullable;
import java.util.List;
/*** /***
* Main render class for Effortless Building * Main render class for Effortless Building
*/ */
@Mod.EventBusSubscriber(value = Dist.CLIENT) @Mod.EventBusSubscriber(value = Dist.CLIENT)
public class RenderHandler implements IWorldEventListener { public class RenderHandler {
@SubscribeEvent @SubscribeEvent
public static void onRender(RenderWorldLastEvent event) { public static void onRender(RenderWorldLastEvent event) {
EntityPlayer player = Minecraft.getInstance().player; PlayerEntity player = Minecraft.getInstance().player;
ModeSettingsManager.ModeSettings modeSettings = ModeSettingsManager.getModeSettings(player); ModeSettingsManager.ModeSettings modeSettings = ModeSettingsManager.getModeSettings(player);
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player); ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
@@ -71,7 +62,7 @@ public class RenderHandler implements IWorldEventListener {
//Display Radial Menu //Display Radial Menu
public static void onRenderGameOverlay(final RenderGameOverlayEvent.Post event) { public static void onRenderGameOverlay(final RenderGameOverlayEvent.Post event) {
Minecraft mc = Minecraft.getInstance(); Minecraft mc = Minecraft.getInstance();
EntityPlayerSP player = mc.player; ClientPlayerEntity player = mc.player;
//check if chisel and bits tool in hand (and has menu) //check if chisel and bits tool in hand (and has menu)
// final boolean hasChiselInHand = CompatHelper.chiselsAndBitsProxy.isHoldingChiselTool(EnumHand.MAIN_HAND); // final boolean hasChiselInHand = CompatHelper.chiselsAndBitsProxy.isHoldingChiselTool(EnumHand.MAIN_HAND);
@@ -150,14 +141,15 @@ public class RenderHandler implements IWorldEventListener {
} }
private static void begin(float partialTicks) { private static void begin(float partialTicks) {
EntityPlayer player = Minecraft.getInstance().player; // PlayerEntity player = Minecraft.getInstance().player;
double playerX = player.prevPosX + (player.posX - player.prevPosX) * partialTicks; // double playerX = player.prevPosX + (player.posX - player.prevPosX) * partialTicks;
double playerY = player.prevPosY + (player.posY - player.prevPosY) * partialTicks; // double playerY = player.prevPosY + (player.posY - player.prevPosY) * partialTicks;
double playerZ = player.prevPosZ + (player.posZ - player.prevPosZ) * partialTicks; // double playerZ = player.prevPosZ + (player.posZ - player.prevPosZ) * partialTicks;
Vec3d playerPos = new Vec3d(playerX, playerY, playerZ); // Vec3d playerPos = new Vec3d(playerX, playerY, playerZ);
GL11.glPushMatrix(); 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); GL11.glDepthMask(false);
} }
@@ -202,7 +194,7 @@ public class RenderHandler implements IWorldEventListener {
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
protected static void renderBlockPreview(BlockRendererDispatcher dispatcher, BlockPos blockPos, IBlockState blockState) { protected static void renderBlockPreview(BlockRendererDispatcher dispatcher, BlockPos blockPos, BlockState blockState) {
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
GlStateManager.translatef(blockPos.getX(), blockPos.getY(), blockPos.getZ()); GlStateManager.translatef(blockPos.getX(), blockPos.getY(), blockPos.getZ());
GlStateManager.rotatef(-90.0F, 0.0F, 1.0F, 0.0F); GlStateManager.rotatef(-90.0F, 0.0F, 1.0F, 0.0F);
@@ -250,80 +242,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); WorldRenderer.drawShape(collisionShape, pos.getX(), pos.getY(), pos.getZ(), (float) color.x, (float) color.y, (float) color.z, 0.4f);
} }
//IWORLDEVENTLISTENER IMPLEMENTATION //TODO 1.14
@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) {
}
//Sends breaking progress for all coordinates to renderglobal, so all blocks get visually broken //Sends breaking progress for all coordinates to renderglobal, so all blocks get visually broken
@Override // @Override
public void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress) { // public void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress) {
Minecraft mc = Minecraft.getInstance(); // Minecraft mc = Minecraft.getInstance();
//
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(mc.player); // ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(mc.player);
if (!BuildModifiers.isEnabled(modifierSettings, pos)) return; // if (!BuildModifiers.isEnabled(modifierSettings, pos)) return;
//
List<BlockPos> coordinates = BuildModifiers.findCoordinates(mc.player, pos); // List<BlockPos> coordinates = BuildModifiers.findCoordinates(mc.player, pos);
for (int i = 1; i < coordinates.size(); i++) { // for (int i = 1; i < coordinates.size(); i++) {
BlockPos coordinate = coordinates.get(i); // BlockPos coordinate = coordinates.get(i);
if (SurvivalHelper.canBreak(mc.world, mc.player, coordinate)) { // if (SurvivalHelper.canBreak(mc.world, mc.player, coordinate)) {
//Send i as entity id because only one block can be broken per id // //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 // //Unless i happens to be the player id, then take something else
int fakeId = mc.player.getEntityId() != i ? i : coordinates.size(); // int fakeId = mc.player.getEntityId() != i ? i : coordinates.size();
mc.renderGlobal.sendBlockBreakProgress(fakeId, coordinate, progress); // mc.renderGlobal.sendBlockBreakProgress(fakeId, coordinate, progress);
} // }
} // }
} // }
} }

View File

@@ -12,7 +12,6 @@
*/ */
package nl.requios.effortlessbuilding.render; package nl.requios.effortlessbuilding.render;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import nl.requios.effortlessbuilding.BuildConfig; import nl.requios.effortlessbuilding.BuildConfig;
import nl.requios.effortlessbuilding.EffortlessBuilding; import nl.requios.effortlessbuilding.EffortlessBuilding;
@@ -74,7 +73,15 @@ public final class ShaderHandler {
} }
public static boolean doUseShaders() { 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) { private static int createProgram(String s, int sides) {