Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c6b58ddc6 | ||
|
|
3921a0b70b | ||
|
|
11cd20c3d3 | ||
|
|
4ce8b1e927 | ||
|
|
0485e6c888 | ||
|
|
89057356df | ||
|
|
a7ac229242 | ||
|
|
b2ee5dbc04 |
3
README.md
Normal file
3
README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
This is the version for Minecraft 1.12.
|
||||
|
||||
1.13 can be found here: https://bitbucket.org/Requios/effortless-building-1.13/src/master/
|
||||
@@ -11,7 +11,7 @@ apply plugin: 'net.minecraftforge.gradle.forge'
|
||||
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
|
||||
|
||||
|
||||
version = "1.12.2-2.9"
|
||||
version = "1.12.2-2.13"
|
||||
group = "nl.requios.effortlessbuilding" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = "effortlessbuilding"
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ public class BuildConfig {
|
||||
|
||||
@Comment({"How many placements are remembered for the undo functionality."})
|
||||
@RequiresMcRestart
|
||||
public int undoStackSize = 5;
|
||||
public int undoStackSize = 10;
|
||||
}
|
||||
|
||||
public static class Visuals {
|
||||
|
||||
@@ -39,7 +39,7 @@ public class EffortlessBuilding
|
||||
{
|
||||
public static final String MODID = "effortlessbuilding";
|
||||
public static final String NAME = "Effortless Building";
|
||||
public static final String VERSION = "1.12.2-2.9";
|
||||
public static final String VERSION = "1.12.2-2.13";
|
||||
|
||||
@Mod.Instance(EffortlessBuilding.MODID)
|
||||
public static EffortlessBuilding instance;
|
||||
@@ -93,11 +93,20 @@ public class EffortlessBuilding
|
||||
EffortlessBuilding.packetHandler.registerMessage(BlockPlacedMessage.MessageHandler.class, BlockPlacedMessage.class, 3, Side.CLIENT);
|
||||
|
||||
EffortlessBuilding.packetHandler.registerMessage(BlockBrokenMessage.MessageHandler.class, BlockBrokenMessage.class, 4, Side.SERVER);
|
||||
EffortlessBuilding.packetHandler.registerMessage(BlockBrokenMessage.MessageHandler.class, BlockBrokenMessage.class, 4, Side.CLIENT);
|
||||
|
||||
EffortlessBuilding.packetHandler.registerMessage(CancelModeMessage.MessageHandler.class, CancelModeMessage.class, 5, Side.SERVER);
|
||||
EffortlessBuilding.packetHandler.registerMessage(CancelModeMessage.MessageHandler.class, CancelModeMessage.class, 5, Side.CLIENT);
|
||||
|
||||
EffortlessBuilding.packetHandler.registerMessage(RequestLookAtMessage.MessageHandler.class, RequestLookAtMessage.class, 6, Side.SERVER);
|
||||
EffortlessBuilding.packetHandler.registerMessage(RequestLookAtMessage.MessageHandler.class, RequestLookAtMessage.class, 6, Side.CLIENT);
|
||||
|
||||
EffortlessBuilding.packetHandler.registerMessage(AddUndoMessage.MessageHandler.class, AddUndoMessage.class, 7, Side.SERVER);
|
||||
EffortlessBuilding.packetHandler.registerMessage(AddUndoMessage.MessageHandler.class, AddUndoMessage.class, 7, Side.CLIENT);
|
||||
|
||||
EffortlessBuilding.packetHandler.registerMessage(ClearUndoMessage.MessageHandler.class, ClearUndoMessage.class, 8, Side.SERVER);
|
||||
EffortlessBuilding.packetHandler.registerMessage(ClearUndoMessage.MessageHandler.class, ClearUndoMessage.class, 8, Side.CLIENT);
|
||||
|
||||
proxy.preInit(event);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@@ -30,6 +31,9 @@ import nl.requios.effortlessbuilding.capability.ModeCapabilityManager;
|
||||
import nl.requios.effortlessbuilding.capability.ModifierCapabilityManager;
|
||||
import nl.requios.effortlessbuilding.helper.ReachHelper;
|
||||
import nl.requios.effortlessbuilding.helper.SurvivalHelper;
|
||||
import nl.requios.effortlessbuilding.network.AddUndoMessage;
|
||||
import nl.requios.effortlessbuilding.network.BlockBrokenMessage;
|
||||
import nl.requios.effortlessbuilding.network.ClearUndoMessage;
|
||||
import nl.requios.effortlessbuilding.network.RequestLookAtMessage;
|
||||
import scala.actors.threadpool.Arrays;
|
||||
|
||||
@@ -91,14 +95,20 @@ public class EventHandler
|
||||
BuildModes.BuildModeEnum buildMode = ModeSettingsManager.getModeSettings(player).getBuildMode();
|
||||
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
|
||||
|
||||
if (buildMode != BuildModes.BuildModeEnum.NORMAL || modifierSettings.doQuickReplace()) {
|
||||
if (buildMode != BuildModes.BuildModeEnum.NORMAL) {
|
||||
event.setCanceled(true);
|
||||
} else if (modifierSettings.doQuickReplace()) {
|
||||
//Cancel event and send message if QuickReplace
|
||||
event.setCanceled(true);
|
||||
EffortlessBuilding.packetHandler.sendTo(new RequestLookAtMessage(true), (EntityPlayerMP) player);
|
||||
EffortlessBuilding.packetHandler.sendTo(new AddUndoMessage(event.getPos(), event.getBlockSnapshot().getReplacedBlock(), event.getState()), (EntityPlayerMP) player);
|
||||
} else {
|
||||
//NORMAL mode, let vanilla handle block placing
|
||||
//But modifiers and QuickReplace should still work
|
||||
//But modifiers should still work
|
||||
|
||||
//Send message to client, which sends message back with raytrace info
|
||||
EffortlessBuilding.packetHandler.sendTo(new RequestLookAtMessage(event.getPos(), event.getBlockSnapshot().getReplacedBlock(), event.getState()), (EntityPlayerMP) player);
|
||||
EffortlessBuilding.packetHandler.sendTo(new RequestLookAtMessage(false), (EntityPlayerMP) player);
|
||||
EffortlessBuilding.packetHandler.sendTo(new AddUndoMessage(event.getPos(), event.getBlockSnapshot().getReplacedBlock(), event.getState()), (EntityPlayerMP) player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,9 +123,12 @@ public class EventHandler
|
||||
event.setCanceled(true);
|
||||
} else {
|
||||
//NORMAL mode, let vanilla handle block breaking
|
||||
//But modifiers and QuickReplace should still work
|
||||
//But modifiers should still work
|
||||
//Dont break the original block yourself, otherwise Tinkers Hammer and Veinminer won't work
|
||||
BuildModes.onBlockBroken(event.getPlayer(), event.getPos(), false);
|
||||
|
||||
//Add to undo stack in client
|
||||
EffortlessBuilding.packetHandler.sendTo(new AddUndoMessage(event.getPos(), event.getState(), Blocks.AIR.getDefaultState()), (EntityPlayerMP) event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,8 +178,11 @@ public class EventHandler
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onPlayerLoggedOut(PlayerLoggedOutEvent event) {
|
||||
UndoRedo.clear(event.player);
|
||||
//TODO call clientside
|
||||
EntityPlayer player = event.player;
|
||||
if (player.getEntityWorld().isRemote) return;
|
||||
|
||||
UndoRedo.clear(player);
|
||||
EffortlessBuilding.packetHandler.sendTo(new ClearUndoMessage(), (EntityPlayerMP) player);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -179,10 +195,12 @@ public class EventHandler
|
||||
@SubscribeEvent
|
||||
public static void onPlayerChangedDimension(PlayerChangedDimensionEvent event) {
|
||||
EntityPlayer player = event.player;
|
||||
if (player.getEntityWorld().isRemote) return;
|
||||
|
||||
ModifierSettingsManager.handleNewPlayer(player);
|
||||
ModeSettingsManager.handleNewPlayer(player);
|
||||
|
||||
UndoRedo.clear(event.player);
|
||||
//TODO call clientside
|
||||
EffortlessBuilding.packetHandler.sendTo(new ClearUndoMessage(), (EntityPlayerMP) player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,16 +135,16 @@ public class BuildModes {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ReachHelper.canBreakFar(player)) return;
|
||||
|
||||
//If first click
|
||||
if (currentlyBreaking.get(player) == null) {
|
||||
//If startpos is null, dont do anything
|
||||
if (startPos == null) return;
|
||||
}
|
||||
|
||||
//Get coordinates
|
||||
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
|
||||
ModeSettingsManager.ModeSettings modeSettings = ModeSettingsManager.getModeSettings(player);
|
||||
|
||||
//Get coordinates
|
||||
BuildModeEnum buildMode = modeSettings.getBuildMode();
|
||||
List<BlockPos> coordinates = buildMode.instance.onRightClick(player, startPos, EnumFacing.UP, Vec3d.ZERO, true);
|
||||
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
package nl.requios.effortlessbuilding.buildmode;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.UndoRedo;
|
||||
import nl.requios.effortlessbuilding.gui.buildmode.RadialMenu;
|
||||
import nl.requios.effortlessbuilding.gui.buildmodifier.ModifierSettingsGui;
|
||||
import nl.requios.effortlessbuilding.proxy.ClientProxy;
|
||||
|
||||
public class ModeOptions {
|
||||
|
||||
@@ -73,7 +68,6 @@ public class ModeOptions {
|
||||
//Called on both client and server
|
||||
public static void performAction(EntityPlayer player, ActionEnum action) {
|
||||
if (action == null) return;
|
||||
BuildModes.BuildModeEnum currentBuildMode = ModeSettingsManager.getModeSettings(Minecraft.getMinecraft().player).getBuildMode();
|
||||
|
||||
switch (action) {
|
||||
case UNDO:
|
||||
@@ -90,7 +84,7 @@ public class ModeOptions {
|
||||
break;
|
||||
case OPEN_MODIFIER_SETTINGS:
|
||||
if (player.world.isRemote)
|
||||
openModifierSettings();
|
||||
ClientProxy.openModifierSettings();
|
||||
break;
|
||||
|
||||
case NORMAL_SPEED:
|
||||
@@ -132,19 +126,7 @@ public class ModeOptions {
|
||||
}
|
||||
|
||||
if (player.world.isRemote && action != ActionEnum.REPLACE && action != ActionEnum.OPEN_MODIFIER_SETTINGS) {
|
||||
logAction(action);
|
||||
ClientProxy.logTranslate(action.name);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO fix client class import giving error on server (nothing happens, it's just ugly)
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static void openModifierSettings() {
|
||||
Minecraft.getMinecraft().displayGuiScreen(new ModifierSettingsGui());
|
||||
RadialMenu.instance.setVisibility(0f);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static void logAction(ActionEnum action) {
|
||||
EffortlessBuilding.log(Minecraft.getMinecraft().player, I18n.format(action.name), true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@ package nl.requios.effortlessbuilding.buildmode;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
import nl.requios.effortlessbuilding.capability.ModeCapabilityManager;
|
||||
import nl.requios.effortlessbuilding.helper.ReachHelper;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package nl.requios.effortlessbuilding.buildmodifier;
|
||||
|
||||
import mod.chiselsandbits.api.IBitLocation;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
@@ -3,6 +3,7 @@ package nl.requios.effortlessbuilding.buildmodifier;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@@ -75,10 +76,19 @@ public class BuildModifiers {
|
||||
}
|
||||
}
|
||||
|
||||
//add to undo stack
|
||||
BlockPos firstPos = startCoordinates.get(0);
|
||||
BlockPos secondPos = startCoordinates.get(startCoordinates.size() - 1);
|
||||
UndoRedo.addUndo(player, new BlockSet(coordinates, previousBlockStates, newBlockStates, hitVec, firstPos, secondPos));
|
||||
//Set first previousBlockState to empty if in NORMAL mode, to make undo/redo work
|
||||
//(Block is placed by the time it gets here, and unplaced after this)
|
||||
if (!placeStartPos) previousBlockStates.set(0, Blocks.AIR.getDefaultState());
|
||||
|
||||
//If all new blockstates are air then no use in adding it, no block was actually placed
|
||||
//Can happen when e.g. placing one block in yourself
|
||||
if (Collections.frequency(newBlockStates, Blocks.AIR.getDefaultState()) != newBlockStates.size()) {
|
||||
//add to undo stack
|
||||
BlockPos firstPos = startCoordinates.get(0);
|
||||
BlockPos secondPos = startCoordinates.get(startCoordinates.size() - 1);
|
||||
UndoRedo.addUndo(player, new BlockSet(coordinates, previousBlockStates, newBlockStates, hitVec, firstPos, secondPos));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void onBlockBroken(EntityPlayer player, List<BlockPos> startCoordinates, boolean breakStartPos) {
|
||||
@@ -100,7 +110,7 @@ public class BuildModifiers {
|
||||
|
||||
//list of air blockstates
|
||||
for (BlockPos coordinate : coordinates) {
|
||||
newBlockStates.add(Block.getBlockById(0).getDefaultState());
|
||||
newBlockStates.add(Blocks.AIR.getDefaultState());
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -125,6 +135,10 @@ public class BuildModifiers {
|
||||
}
|
||||
}
|
||||
|
||||
//Set first newBlockState to empty if in NORMAL mode, to make undo/redo work
|
||||
//(Block isn't broken yet by the time it gets here, and broken after this)
|
||||
if (!breakStartPos) newBlockStates.set(0, Blocks.AIR.getDefaultState());
|
||||
|
||||
//add to undo stack
|
||||
BlockPos firstPos = startCoordinates.get(0);
|
||||
BlockPos secondPos = startCoordinates.get(startCoordinates.size() - 1);
|
||||
|
||||
@@ -3,8 +3,6 @@ package nl.requios.effortlessbuilding.buildmodifier;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
|
||||
import nl.requios.effortlessbuilding.BuildConfig;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
import nl.requios.effortlessbuilding.capability.ModifierCapabilityManager;
|
||||
|
||||
@@ -3,6 +3,7 @@ package nl.requios.effortlessbuilding.buildmodifier;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -31,17 +32,36 @@ public class UndoRedo {
|
||||
public static void addUndo(EntityPlayer player, BlockSet blockSet) {
|
||||
Map<UUID, FixedStack<BlockSet>> undoStacks = player.world.isRemote ? undoStacksClient : undoStacksServer;
|
||||
|
||||
//Assert coordinates is as long as previous and new blockstate lists
|
||||
if (blockSet.getCoordinates().size() != blockSet.getPreviousBlockStates().size() ||
|
||||
blockSet.getCoordinates().size() != blockSet.getNewBlockStates().size()) {
|
||||
EffortlessBuilding.logger.error("Coordinates and blockstate lists are not equal length. Coordinates: {}. Previous blockstates: {}. New blockstates: {}.",
|
||||
blockSet.getCoordinates().size(), blockSet.getPreviousBlockStates().size(), blockSet.getNewBlockStates().size());
|
||||
}
|
||||
|
||||
//Warn if previous and new blockstate are equal
|
||||
//Can happen in a lot of valid cases
|
||||
// for (int i = 0; i < blockSet.getCoordinates().size(); i++) {
|
||||
// if (blockSet.getPreviousBlockStates().get(i).equals(blockSet.getNewBlockStates().get(i))) {
|
||||
// EffortlessBuilding.logger.warn("Previous and new blockstates are equal at index {}. Blockstate: {}.",
|
||||
// i, blockSet.getPreviousBlockStates().get(i));
|
||||
// }
|
||||
// }
|
||||
|
||||
//If no stack exists, make one
|
||||
if (!undoStacks.containsKey(player.getUniqueID())) {
|
||||
undoStacks.put(player.getUniqueID(), new FixedStack<>(new BlockSet[BuildConfig.survivalBalancers.undoStackSize]));
|
||||
}
|
||||
|
||||
|
||||
undoStacks.get(player.getUniqueID()).push(blockSet);
|
||||
}
|
||||
|
||||
private static void addRedo(EntityPlayer player, BlockSet blockSet) {
|
||||
Map<UUID, FixedStack<BlockSet>> redoStacks = player.world.isRemote ? redoStacksClient : redoStacksServer;
|
||||
|
||||
//(No asserts necessary, it's private)
|
||||
|
||||
//If no stack exists, make one
|
||||
if (!redoStacks.containsKey(player.getUniqueID())) {
|
||||
redoStacks.put(player.getUniqueID(), new FixedStack<>(new BlockSet[BuildConfig.survivalBalancers.undoStackSize]));
|
||||
@@ -76,10 +96,12 @@ public class UndoRedo {
|
||||
BlockPos coordinate = coordinates.get(i);
|
||||
ItemStack itemStack = itemStacks.get(i);
|
||||
|
||||
if (previousBlockStates.get(i).equals(newBlockStates.get(i))) continue;
|
||||
|
||||
//get blockstate from itemstack
|
||||
IBlockState previousBlockState = Block.getBlockById(0).getDefaultState();
|
||||
IBlockState previousBlockState = Blocks.AIR.getDefaultState();
|
||||
if (itemStack.getItem() instanceof ItemBlock) {
|
||||
previousBlockState = ((ItemBlock) itemStack.getItem()).getBlock().getDefaultState();
|
||||
previousBlockState = previousBlockStates.get(i);//((ItemBlock) itemStack.getItem()).getBlock().getDefaultState();
|
||||
}
|
||||
|
||||
if (player.world.isBlockLoaded(coordinate, true)) {
|
||||
@@ -88,7 +110,9 @@ public class UndoRedo {
|
||||
itemStack = findItemStackInInventory(player, previousBlockStates.get(i));
|
||||
//get blockstate from new itemstack
|
||||
if (!itemStack.isEmpty() && itemStack.getItem() instanceof ItemBlock) {
|
||||
previousBlockState = ((ItemBlock) itemStack.getItem()).getBlock().getDefaultState();
|
||||
previousBlockState = previousBlockStates.get(i);//((ItemBlock) itemStack.getItem()).getBlock().getDefaultState();
|
||||
} else {
|
||||
previousBlockState = Blocks.AIR.getDefaultState();
|
||||
}
|
||||
}
|
||||
if (itemStack.isEmpty()) SurvivalHelper.breakBlock(player.world, player, coordinate, true);
|
||||
@@ -115,6 +139,7 @@ public class UndoRedo {
|
||||
|
||||
BlockSet blockSet = redoStack.pop();
|
||||
List<BlockPos> coordinates = blockSet.getCoordinates();
|
||||
List<IBlockState> previousBlockStates = blockSet.getPreviousBlockStates();
|
||||
List<IBlockState> newBlockStates = blockSet.getNewBlockStates();
|
||||
Vec3d hitVec = blockSet.getHitVec();
|
||||
|
||||
@@ -127,16 +152,25 @@ public class UndoRedo {
|
||||
//place blocks
|
||||
for (int i = 0; i < coordinates.size(); i++) {
|
||||
BlockPos coordinate = coordinates.get(i);
|
||||
IBlockState newBlockState = newBlockStates.get(i);
|
||||
ItemStack itemStack = itemStacks.get(i);
|
||||
|
||||
if (previousBlockStates.get(i).equals(newBlockStates.get(i))) continue;
|
||||
|
||||
//get blockstate from itemstack
|
||||
IBlockState newBlockState = Blocks.AIR.getDefaultState();
|
||||
if (itemStack.getItem() instanceof ItemBlock) {
|
||||
newBlockState = newBlockStates.get(i);//((ItemBlock) itemStack.getItem()).getBlock().getDefaultState();
|
||||
}
|
||||
|
||||
if (player.world.isBlockLoaded(coordinate, true)) {
|
||||
//check itemstack empty
|
||||
if (itemStack.isEmpty()) {
|
||||
itemStack = findItemStackInInventory(player, newBlockStates.get(i));
|
||||
//get blockstate from new itemstack
|
||||
if (!itemStack.isEmpty() && itemStack.getItem() instanceof ItemBlock) {
|
||||
newBlockState = ((ItemBlock) itemStack.getItem()).getBlock().getDefaultState();
|
||||
newBlockState = newBlockStates.get(i);//((ItemBlock) itemStack.getItem()).getBlock().getDefaultState();
|
||||
} else {
|
||||
newBlockState = Blocks.AIR.getDefaultState();
|
||||
}
|
||||
}
|
||||
if (itemStack.isEmpty()) SurvivalHelper.breakBlock(player.world, player, coordinate, true);
|
||||
@@ -174,6 +208,8 @@ public class UndoRedo {
|
||||
ItemStack itemStack = ItemStack.EMPTY;
|
||||
|
||||
//First try previousBlockStates
|
||||
//TODO try to find itemstack with right blockstate first
|
||||
// then change line 103 back (get state from item)
|
||||
itemStack = InventoryHelper.findItemStackInInventory(player, blockState.getBlock());
|
||||
|
||||
//then anything it drops
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package nl.requios.effortlessbuilding.compatibility;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
@@ -63,9 +65,9 @@ public class CompatHelper {
|
||||
}
|
||||
|
||||
//Dank Null
|
||||
if(proxyItem == dankNullItem) {
|
||||
if (proxyItem == dankNullItem) {
|
||||
int index = 0;
|
||||
if(proxy.hasTagCompound() && proxy.getTagCompound().hasKey("selectedIndex"))
|
||||
if (proxy.hasTagCompound() && proxy.getTagCompound().hasKey("selectedIndex"))
|
||||
index = proxy.getTagCompound().getInteger("selectedIndex");
|
||||
return proxy.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null).getStackInSlot(index);
|
||||
}
|
||||
@@ -75,14 +77,14 @@ public class CompatHelper {
|
||||
|
||||
public static ItemStack getItemBlockByState(ItemStack stack, IBlockState state) {
|
||||
Item blockItem = Item.getItemFromBlock(state.getBlock());
|
||||
if(stack.getItem() instanceof ItemBlock)
|
||||
if (stack.getItem() instanceof ItemBlock)
|
||||
return stack;
|
||||
else if(stack.getItem() instanceof ItemRandomizerBag) {
|
||||
else if (stack.getItem() instanceof ItemRandomizerBag) {
|
||||
IItemHandler bagInventory = ItemRandomizerBag.getBagInventory(stack);
|
||||
return ItemRandomizerBag.findStack(bagInventory, blockItem);
|
||||
} else if(stack.getItem() == dankNullItem) {
|
||||
} else if (stack.getItem() == dankNullItem) {
|
||||
int index = itemHandlerSlotForItem(stack, blockItem);
|
||||
if(index >= 0)
|
||||
if (index >= 0)
|
||||
return stack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null).getStackInSlot(index);
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
@@ -90,8 +92,11 @@ public class CompatHelper {
|
||||
|
||||
// Handle IItemHandler slot stacks not being modifiable. We must call IItemHandler#extractItem,
|
||||
// because the ItemStack returned by IItemHandler#getStackInSlot isn't modifiable.
|
||||
public static void shrinkStack(ItemStack origStack, ItemStack curStack) {
|
||||
if(origStack.getItem() == dankNullItem) {
|
||||
public static void shrinkStack(ItemStack origStack, ItemStack curStack, EntityPlayer player) {
|
||||
//Hacky way to get the origstack, because given origStack is itemblock stack and never a proxy
|
||||
origStack = player.getHeldItem(EnumHand.MAIN_HAND);
|
||||
|
||||
if (origStack.getItem() == dankNullItem) {
|
||||
int index = itemHandlerSlotForItem(origStack, curStack.getItem());
|
||||
origStack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null).extractItem(index, 1, false);
|
||||
} else
|
||||
@@ -100,10 +105,10 @@ public class CompatHelper {
|
||||
|
||||
private static int itemHandlerSlotForItem(ItemStack stack, Item blockItem) {
|
||||
IItemHandler handler = stack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
|
||||
for(int i = 0; i < handler.getSlots(); i++) {
|
||||
for (int i = 0; i < handler.getSlots(); i++) {
|
||||
ItemStack ref = handler.getStackInSlot(i);
|
||||
if(ref.getItem() instanceof ItemBlock)
|
||||
if(ref.getItem() == blockItem)
|
||||
if (ref.getItem() instanceof ItemBlock)
|
||||
if (ref.getItem() == blockItem)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
|
||||
@@ -28,12 +28,20 @@ public class ReachHelper {
|
||||
|
||||
public static int getMaxBlocksPlacedAtOnce(EntityPlayer player) {
|
||||
if (player.isCreative()) return 1000000;
|
||||
return getMaxReach(player) * 5;
|
||||
return MathHelper.ceil(Math.pow(getMaxReach(player), 1.6));
|
||||
//Level 0: 121
|
||||
//Level 1: 523
|
||||
//Level 2: 1585
|
||||
//Level 3: 4805
|
||||
}
|
||||
|
||||
public static int getMaxBlocksPerAxis(EntityPlayer player) {
|
||||
if (player.isCreative()) return 2000;
|
||||
return MathHelper.ceil(MathHelper.sqrt(getMaxReach(player)));
|
||||
return MathHelper.ceil(getMaxReach(player) * 0.3);
|
||||
//Level 0: 6
|
||||
//Level 1: 15
|
||||
//Level 2: 30
|
||||
//Level 3: 60
|
||||
}
|
||||
|
||||
public static boolean canBreakFar(EntityPlayer player) {
|
||||
|
||||
@@ -71,7 +71,7 @@ public class SurvivalHelper {
|
||||
}
|
||||
|
||||
if (!player.isCreative() && Block.getBlockFromItem(itemstack.getItem()) == block) {
|
||||
CompatHelper.shrinkStack(origstack, itemstack);
|
||||
CompatHelper.shrinkStack(origstack, itemstack, player);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
package nl.requios.effortlessbuilding.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.BlockSet;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.UndoRedo;
|
||||
import nl.requios.effortlessbuilding.proxy.ClientProxy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/***
|
||||
* Sends a message to the client asking to add a block to the undo stack.
|
||||
*/
|
||||
public class AddUndoMessage implements IMessage {
|
||||
private BlockPos coordinate;
|
||||
private IBlockState previousBlockState;
|
||||
private IBlockState newBlockState;
|
||||
|
||||
public AddUndoMessage() {
|
||||
coordinate = BlockPos.ORIGIN;
|
||||
previousBlockState = null;
|
||||
newBlockState = null;
|
||||
}
|
||||
|
||||
public AddUndoMessage(BlockPos coordinate, IBlockState previousBlockState, IBlockState newBlockState) {
|
||||
this.coordinate = coordinate;
|
||||
this.previousBlockState = previousBlockState;
|
||||
this.newBlockState = newBlockState;
|
||||
}
|
||||
|
||||
public BlockPos getCoordinate() {
|
||||
return coordinate;
|
||||
}
|
||||
|
||||
public IBlockState getPreviousBlockState() {
|
||||
return previousBlockState;
|
||||
}
|
||||
|
||||
public IBlockState getNewBlockState() {
|
||||
return newBlockState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(this.coordinate.getX());
|
||||
buf.writeInt(this.coordinate.getY());
|
||||
buf.writeInt(this.coordinate.getZ());
|
||||
buf.writeInt(Block.getStateId(this.previousBlockState));
|
||||
buf.writeInt(Block.getStateId(this.newBlockState));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
coordinate = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt());
|
||||
previousBlockState = Block.getStateById(buf.readInt());
|
||||
newBlockState = Block.getStateById(buf.readInt());
|
||||
}
|
||||
|
||||
// The params of the IMessageHandler are <REQ, REPLY>
|
||||
public static class MessageHandler implements IMessageHandler<AddUndoMessage, IMessage> {
|
||||
// Do note that the default constructor is required, but implicitly defined in this case
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(AddUndoMessage message, MessageContext ctx) {
|
||||
//EffortlessBuilding.log("message received on " + ctx.side + " side");
|
||||
|
||||
if (ctx.side == Side.CLIENT){
|
||||
//Received clientside
|
||||
|
||||
EffortlessBuilding.proxy.getThreadListenerFromContext(ctx).addScheduledTask(() -> {
|
||||
EntityPlayer player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx);
|
||||
|
||||
//Add to undo stack clientside
|
||||
UndoRedo.addUndo(player, new BlockSet(
|
||||
new ArrayList<BlockPos>() {{add(message.getCoordinate());}},
|
||||
new ArrayList<IBlockState>() {{add(message.getPreviousBlockState());}},
|
||||
new ArrayList<IBlockState>() {{add(message.getNewBlockState());}},
|
||||
new Vec3d(0,0,0),
|
||||
message.getCoordinate(), message.getCoordinate()));
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package nl.requios.effortlessbuilding.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.BlockSet;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.UndoRedo;
|
||||
import nl.requios.effortlessbuilding.proxy.ClientProxy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/***
|
||||
* Sends a message to the client asking to clear the undo and redo stacks.
|
||||
*/
|
||||
public class ClearUndoMessage implements IMessage {
|
||||
|
||||
public ClearUndoMessage() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
}
|
||||
|
||||
// The params of the IMessageHandler are <REQ, REPLY>
|
||||
public static class MessageHandler implements IMessageHandler<ClearUndoMessage, IMessage> {
|
||||
// Do note that the default constructor is required, but implicitly defined in this case
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(ClearUndoMessage message, MessageContext ctx) {
|
||||
//EffortlessBuilding.log("message received on " + ctx.side + " side");
|
||||
|
||||
if (ctx.side == Side.CLIENT){
|
||||
//Received clientside
|
||||
|
||||
EffortlessBuilding.proxy.getThreadListenerFromContext(ctx).addScheduledTask(() -> {
|
||||
EntityPlayer player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx);
|
||||
|
||||
//Add to undo stack clientside
|
||||
UndoRedo.clear(player);
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,48 +22,28 @@ import java.util.ArrayList;
|
||||
* This is then sent back with a BlockPlacedMessage.
|
||||
*/
|
||||
public class RequestLookAtMessage implements IMessage {
|
||||
private BlockPos coordinate;
|
||||
private IBlockState previousBlockState;
|
||||
private IBlockState newBlockState;
|
||||
private boolean placeStartPos;
|
||||
|
||||
public RequestLookAtMessage() {
|
||||
coordinate = BlockPos.ORIGIN;
|
||||
previousBlockState = null;
|
||||
newBlockState = null;
|
||||
placeStartPos = false;
|
||||
}
|
||||
|
||||
public RequestLookAtMessage(BlockPos coordinate, IBlockState previousBlockState, IBlockState newBlockState) {
|
||||
this.coordinate = coordinate;
|
||||
this.previousBlockState = previousBlockState;
|
||||
this.newBlockState = newBlockState;
|
||||
public RequestLookAtMessage(boolean placeStartPos) {
|
||||
this.placeStartPos = placeStartPos;
|
||||
}
|
||||
|
||||
public BlockPos getCoordinate() {
|
||||
return coordinate;
|
||||
}
|
||||
|
||||
public IBlockState getPreviousBlockState() {
|
||||
return previousBlockState;
|
||||
}
|
||||
|
||||
public IBlockState getNewBlockState() {
|
||||
return newBlockState;
|
||||
public boolean getPlaceStartPos() {
|
||||
return placeStartPos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(this.coordinate.getX());
|
||||
buf.writeInt(this.coordinate.getY());
|
||||
buf.writeInt(this.coordinate.getZ());
|
||||
buf.writeInt(Block.getStateId(this.previousBlockState));
|
||||
buf.writeInt(Block.getStateId(this.newBlockState));
|
||||
buf.writeBoolean(this.placeStartPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
coordinate = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt());
|
||||
previousBlockState = Block.getStateById(buf.readInt());
|
||||
newBlockState = Block.getStateById(buf.readInt());
|
||||
placeStartPos = buf.readBoolean();
|
||||
}
|
||||
|
||||
// The params of the IMessageHandler are <REQ, REPLY>
|
||||
@@ -78,20 +58,14 @@ public class RequestLookAtMessage implements IMessage {
|
||||
//Received clientside
|
||||
//Send back your info
|
||||
|
||||
EffortlessBuilding.proxy.getThreadListenerFromContext(ctx).addScheduledTask(() -> {
|
||||
EntityPlayer player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx);
|
||||
// EffortlessBuilding.proxy.getThreadListenerFromContext(ctx).addScheduledTask(() -> {
|
||||
// EntityPlayer player = EffortlessBuilding.proxy.getPlayerEntityFromContext(ctx);
|
||||
//
|
||||
// });
|
||||
|
||||
//Add to undo stack clientside
|
||||
UndoRedo.addUndo(player, new BlockSet(
|
||||
new ArrayList<BlockPos>() {{add(message.getCoordinate());}},
|
||||
new ArrayList<IBlockState>() {{add(message.getPreviousBlockState());}},
|
||||
new ArrayList<IBlockState>() {{add(message.getNewBlockState());}},
|
||||
new Vec3d(0,0,0),
|
||||
message.getCoordinate(), message.getCoordinate()));
|
||||
});
|
||||
|
||||
//Prevent double placing in normal mode with placeStartPos false
|
||||
return new BlockPlacedMessage(ClientProxy.previousLookAt, false);
|
||||
//Prevent double placing in normal mode with placeStartPos false.
|
||||
//Unless QuickReplace is on, then we do need to place start pos.
|
||||
return new BlockPlacedMessage(ClientProxy.previousLookAt, message.getPlaceStartPos());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
@@ -260,6 +261,11 @@ public class ClientProxy implements IProxy {
|
||||
//Break block in distance in creative (or survival if enabled in config)
|
||||
if (breakCooldown <= 0) {
|
||||
breakCooldown = 4;
|
||||
|
||||
//Early out if cant break far, coming from own mouse event (not block broken event)
|
||||
//To make breaking blocks in survival possible without breaking instantly
|
||||
if (!ReachHelper.canBreakFar(player)) return;
|
||||
|
||||
RayTraceResult lookingAt = getLookingAt(player);
|
||||
|
||||
BuildModes.onBlockBrokenMessage(player, lookingAt == null ? new BlockBrokenMessage() : new BlockBrokenMessage(lookingAt));
|
||||
@@ -278,6 +284,7 @@ public class ClientProxy implements IProxy {
|
||||
}
|
||||
} else if (buildMode == BuildModes.BuildModeEnum.NORMAL_PLUS) {
|
||||
breakCooldown--;
|
||||
if (ModeOptions.getBuildSpeed() == ModeOptions.ActionEnum.FAST_SPEED) breakCooldown = 0;
|
||||
}
|
||||
|
||||
//EffortlessBuilding.packetHandler.sendToServer(new CancelModeMessage());
|
||||
@@ -301,16 +308,7 @@ public class ClientProxy implements IProxy {
|
||||
//Remember to send packet to server if necessary
|
||||
//Show Modifier Settings GUI
|
||||
if (keyBindings[0].isPressed()) {
|
||||
//Disabled if max reach is 0, might be set in the config that way.
|
||||
if (ReachHelper.getMaxReach(player) == 0) {
|
||||
EffortlessBuilding.log(player, "Build modifiers are disabled until your reach has increased. Increase your reach with craftable reach upgrades.");
|
||||
} else {
|
||||
if (Minecraft.getMinecraft().currentScreen == null) {
|
||||
Minecraft.getMinecraft().displayGuiScreen(new ModifierSettingsGui());
|
||||
} else {
|
||||
player.closeScreen();
|
||||
}
|
||||
}
|
||||
openModifierSettings();
|
||||
}
|
||||
|
||||
//QuickReplace toggle
|
||||
@@ -353,6 +351,23 @@ public class ClientProxy implements IProxy {
|
||||
|
||||
}
|
||||
|
||||
public static void openModifierSettings() {
|
||||
EntityPlayerSP player = Minecraft.getMinecraft().player;
|
||||
|
||||
RadialMenu.instance.setVisibility(0f);
|
||||
|
||||
//Disabled if max reach is 0, might be set in the config that way.
|
||||
if (ReachHelper.getMaxReach(player) == 0) {
|
||||
EffortlessBuilding.log(player, "Build modifiers are disabled until your reach has increased. Increase your reach with craftable reach upgrades.");
|
||||
} else {
|
||||
if (Minecraft.getMinecraft().currentScreen == null) {
|
||||
Minecraft.getMinecraft().displayGuiScreen(new ModifierSettingsGui());
|
||||
} else {
|
||||
player.closeScreen();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onGuiOpen(GuiOpenEvent event) {
|
||||
EntityPlayer player = Minecraft.getMinecraft().player;
|
||||
@@ -374,4 +389,8 @@ public class ClientProxy implements IProxy {
|
||||
return player.rayTrace(raytraceRange, 1f);
|
||||
// return world.rayTraceBlocks(start, end, false, false, false);
|
||||
}
|
||||
|
||||
public static void logTranslate(String key) {
|
||||
EffortlessBuilding.log(Minecraft.getMinecraft().player, I18n.format(key), true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,8 @@ public class BlockPreviewRenderer {
|
||||
|
||||
private static List<PlacedData> placedDataList = new ArrayList<>();
|
||||
|
||||
private static final int secondaryTextureUnit = 7;
|
||||
private static final int primaryTextureUnit = 0;
|
||||
private static final int secondaryTextureUnit = 2;
|
||||
|
||||
public static void render(EntityPlayer player, ModifierSettings modifierSettings, ModeSettings modeSettings) {
|
||||
|
||||
@@ -381,20 +382,18 @@ public class BlockPreviewRenderer {
|
||||
int imageUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "image");
|
||||
int maskUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "mask");
|
||||
|
||||
//image
|
||||
OpenGlHelper.setActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB);
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, mc.renderEngine.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).getGlTextureId());
|
||||
ARBShaderObjects.glUniform1iARB(imageUniform, 0);
|
||||
|
||||
OpenGlHelper.setActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + secondaryTextureUnit);
|
||||
|
||||
GlStateManager.enableTexture2D();
|
||||
GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
|
||||
|
||||
//mask
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D,
|
||||
mc.renderEngine.getTexture(new ResourceLocation(EffortlessBuilding.MODID, "textures/shader_mask.png")).getGlTextureId());
|
||||
ARBShaderObjects.glUniform1iARB(maskUniform, secondaryTextureUnit);
|
||||
OpenGlHelper.setActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + secondaryTextureUnit);
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, mc.renderEngine.getTexture(ShaderHandler.shaderMaskTextureLocation).getGlTextureId());
|
||||
|
||||
//image
|
||||
ARBShaderObjects.glUniform1iARB(imageUniform, primaryTextureUnit);
|
||||
OpenGlHelper.setActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + primaryTextureUnit);
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, mc.renderEngine.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).getGlTextureId());
|
||||
|
||||
//blockpos
|
||||
ARBShaderObjects.glUniform3fARB(blockposUniform, (float) blockpos.x, (float) blockpos.y, (float) blockpos.z);
|
||||
|
||||
@@ -185,8 +185,8 @@ public class RenderHandler implements IWorldEventListener {
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(EffortlessBuilding.MODID, "textures/shader_mask.png"));
|
||||
// Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(ShaderHandler.shaderMaskTextureLocation);
|
||||
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
@@ -196,6 +196,7 @@ public class RenderHandler implements IWorldEventListener {
|
||||
protected static void endBlockPreviews() {
|
||||
ShaderHandler.releaseShader();
|
||||
GlStateManager.disableBlend();
|
||||
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
package nl.requios.effortlessbuilding.render;
|
||||
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import nl.requios.effortlessbuilding.BuildConfig;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
import nl.requios.effortlessbuilding.proxy.ClientProxy;
|
||||
@@ -39,6 +40,8 @@ public final class ShaderHandler {
|
||||
public static int rawColor;
|
||||
public static int dissolve;
|
||||
|
||||
public static ResourceLocation shaderMaskTextureLocation = new ResourceLocation(EffortlessBuilding.MODID, "textures/shader_mask.png");
|
||||
|
||||
public static void init() {
|
||||
if(!doUseShaders())
|
||||
return;
|
||||
|
||||
@@ -31,9 +31,7 @@ void main() {
|
||||
float placeFromFirst = length(worldpos - firstposc) / firstToSecond;
|
||||
float placeFromSecond = length(worldpos - secondposc) / firstToSecond;
|
||||
place = (placeFromFirst + (1.0 - placeFromSecond)) / 2.0;
|
||||
} else {
|
||||
//only one block
|
||||
}
|
||||
} //else only one block
|
||||
|
||||
//find 2d texture coordinate for noise texture based on world position
|
||||
vec2 maskcoord = vec2(worldpos.y, worldpos.z);
|
||||
@@ -80,8 +78,8 @@ void main() {
|
||||
// color.rgb += vec3(0.5 - smoothstep(0, 0.5, distToEdge)) * 0.5;
|
||||
|
||||
//add flat shading
|
||||
if (abs(normal.x) > 0.5)
|
||||
color.rgb -= 0.0;
|
||||
// if (abs(normal.x) > 0.5)
|
||||
// color.rgb -= 0.0;
|
||||
if (abs(normal.y) > 0.5)
|
||||
color.rgb += 0.05;
|
||||
if (abs(normal.z) > 0.5)
|
||||
|
||||
Reference in New Issue
Block a user