mirror of
https://github.com/GTNewHorizons/StorageDrawers.git
synced 2026-11-22 05:02:12 +00:00
Merge branch 'drawer_holdclick' into dev
This commit is contained in:
11 files changed
+283
-90
No files matched your search
+6
-6
@@ -41,7 +41,7 @@ developmentEnvironmentUserName = Developer
|
||||
|
||||
# Enables using modern Java syntax (up to version 17) via Jabel, while still targeting JVM 8.
|
||||
# See https://github.com/bsideup/jabel for details on how this works.
|
||||
enableModernJavaSyntax = false
|
||||
enableModernJavaSyntax = true
|
||||
|
||||
# Enables injecting missing generics into the decompiled source code for a better coding experience.
|
||||
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
|
||||
@@ -80,10 +80,10 @@ apiPackage = api
|
||||
# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/
|
||||
# There can be multiple files in a space-separated list.
|
||||
# Example value: mymodid_at.cfg nei_at.cfg
|
||||
accessTransformersFile =
|
||||
accessTransformersFile = storagedrawers_at.cfg
|
||||
|
||||
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
|
||||
usesMixins = false
|
||||
usesMixins = true
|
||||
|
||||
# Set to a non-empty string to configure mixins in a separate source set under src/VALUE, instead of src/main.
|
||||
# This can speed up compile times thanks to not running the mixin annotation processor on all input sources.
|
||||
@@ -91,7 +91,7 @@ usesMixins = false
|
||||
separateMixinSourceSet =
|
||||
|
||||
# Adds some debug arguments like verbose output and class export.
|
||||
usesMixinDebug = false
|
||||
usesMixinDebug = true
|
||||
|
||||
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
|
||||
mixinPlugin =
|
||||
@@ -99,12 +99,12 @@ mixinPlugin =
|
||||
# Specify the package that contains all of your Mixins. The package must exist or
|
||||
# the build will fail. If you have a package property defined in your mixins.<modid>.json,
|
||||
# it must match with this or the build will fail.
|
||||
mixinsPackage =
|
||||
mixinsPackage = mixins
|
||||
|
||||
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
|
||||
# This parameter is for legacy compatibility only
|
||||
# Example value: (coreModClass = asm.FMLPlugin) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.asm.FMLPlugin
|
||||
coreModClass =
|
||||
coreModClass = mixins.EarlyMixinsLoader
|
||||
|
||||
# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class
|
||||
# that is annotated with @Mod) you want this to be true. When in doubt: leave it on false!
|
||||
|
||||
@@ -47,7 +47,7 @@ public class BlockCompDrawers extends BlockDrawers implements INetworked {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getDrawerSlot(int side, float hitX, float hitY, float hitZ) {
|
||||
public int getDrawerSlot(int side, float hitX, float hitY, float hitZ) {
|
||||
if (hitTop(hitY)) return 0;
|
||||
|
||||
if (hitLeft(side, hitX, hitZ)) return 1;
|
||||
|
||||
@@ -36,8 +36,6 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
|
||||
import org.apache.commons.compress.utils.IOUtils;
|
||||
import org.apache.logging.log4j.Level;
|
||||
@@ -61,7 +59,6 @@ import com.jaquadro.minecraft.storagedrawers.item.ItemPersonalKey;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemTrim;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemUpgrade;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemUpgradeCreative;
|
||||
import com.jaquadro.minecraft.storagedrawers.network.BlockClickMessage;
|
||||
import com.jaquadro.minecraft.storagedrawers.security.SecurityManager;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
@@ -72,7 +69,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import fox.spiteful.avaritia.items.ItemMatterCluster;
|
||||
import xonin.backhand.api.core.BackhandUtils;
|
||||
|
||||
public class BlockDrawers extends BlockContainer implements IExtendedBlockClickHandler, INetworked {
|
||||
public class BlockDrawers extends BlockContainer implements INetworked, IExtendedBlockClickHandler {
|
||||
|
||||
private static final ResourceLocation blockConfig = new ResourceLocation(
|
||||
StorageDrawers.MOD_ID + ":textures/blocks/block_config.mcmeta");
|
||||
@@ -450,7 +447,7 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
|
||||
return false;
|
||||
}
|
||||
|
||||
protected int getDrawerSlot(int side, float hitX, float hitY, float hitZ) {
|
||||
public int getDrawerSlot(int side, float hitX, float hitY, float hitZ) {
|
||||
if (drawerCount == 1) return 0;
|
||||
if (drawerCount == 2) return hitTop(hitY) ? 0 : 1;
|
||||
|
||||
@@ -477,77 +474,6 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) {
|
||||
if (world.isRemote) {
|
||||
MovingObjectPosition posn = Minecraft.getMinecraft().objectMouseOver;
|
||||
float hitX = (float) (posn.hitVec.xCoord - posn.blockX);
|
||||
float hitY = (float) (posn.hitVec.yCoord - posn.blockY);
|
||||
float hitZ = (float) (posn.hitVec.zCoord - posn.blockZ);
|
||||
|
||||
StorageDrawers.network.sendToServer(
|
||||
new BlockClickMessage(
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
posn.sideHit,
|
||||
hitX,
|
||||
hitY,
|
||||
hitZ,
|
||||
StorageDrawers.config.cache.invertShift));
|
||||
|
||||
if (StorageDrawers.config.cache.debugTrace)
|
||||
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, "BlockDrawers.onBlockClicked with " + posn);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY,
|
||||
float hitZ, boolean invertShift) {
|
||||
if (StorageDrawers.config.cache.debugTrace)
|
||||
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, "IExtendedBlockClickHandler.onBlockClicked");
|
||||
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
PlayerInteractEvent event = ForgeEventFactory
|
||||
.onPlayerInteract(player, PlayerInteractEvent.Action.LEFT_CLICK_BLOCK, x, y, z, side, world);
|
||||
if (event.isCanceled()) return;
|
||||
}
|
||||
|
||||
TileEntityDrawers tileDrawers = getTileEntitySafe(world, x, y, z);
|
||||
if (tileDrawers.getDirection() != side) return;
|
||||
|
||||
if (tileDrawers.isSealed()) return;
|
||||
|
||||
if (!SecurityManager.hasAccess(player.getGameProfile(), tileDrawers)) return;
|
||||
|
||||
int slot = getDrawerSlot(side, hitX, hitY, hitZ);
|
||||
IDrawer drawer = tileDrawers.getDrawer(slot);
|
||||
if (drawer == null) return;
|
||||
|
||||
final ItemStack item;
|
||||
// if invertSHift is true this will happen when the player is not shifting
|
||||
if (player.isSneaking() != invertShift)
|
||||
item = tileDrawers.takeItemsFromSlot(slot, drawer.getStoredItemStackSize());
|
||||
else item = tileDrawers.takeItemsFromSlot(slot, 1);
|
||||
|
||||
if (StorageDrawers.config.cache.debugTrace)
|
||||
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, (item == null) ? " null item" : " " + item);
|
||||
|
||||
if (item != null && item.stackSize > 0) {
|
||||
if (!player.inventory.addItemStackToInventory(item)) {
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(side);
|
||||
dropItemStack(world, x + dir.offsetX, y, z + dir.offsetZ, item);
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
} else world.playSoundEffect(
|
||||
x + .5f,
|
||||
y + .5f,
|
||||
z + .5f,
|
||||
"random.pop",
|
||||
.2f,
|
||||
((world.rand.nextFloat() - world.rand.nextFloat()) * .7f + 1) * 2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) {
|
||||
TileEntityDrawers tile = getTileEntitySafe(world, x, y, z);
|
||||
@@ -570,6 +496,13 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY,
|
||||
float hitZ, boolean invertShift) {
|
||||
TileEntityDrawers ted = getTileEntitySafe(world, x, y, z);
|
||||
ted.onClick(player, x, y, z, side, world, hitX, hitY, hitZ, invertShift);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) {
|
||||
if (halfDepth) return false;
|
||||
@@ -583,7 +516,7 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
|
||||
return side.ordinal() != getTileEntity(world, x, y, z).getDirection();
|
||||
}
|
||||
|
||||
private void dropItemStack(World world, int x, int y, int z, ItemStack stack) {
|
||||
public void dropItemStack(World world, int x, int y, int z, ItemStack stack) {
|
||||
EntityItem entity = new EntityItem(world, x + .5f, y + .5f, z + .5f, stack);
|
||||
entity.addVelocity(-entity.motionX, -entity.motionY, -entity.motionZ);
|
||||
world.spawnEntityInWorld(entity);
|
||||
@@ -650,7 +583,7 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
|
||||
if (!drawer.isDrawerEnabled(drawerIndex)) return;
|
||||
IDrawer subDrawer = drawer.getDrawer(drawerIndex);
|
||||
while (subDrawer.getStoredItemCount() > 0) {
|
||||
ItemStack stack = drawer.takeItemsFromSlot(drawerIndex, subDrawer.getStoredItemStackSize());
|
||||
ItemStack stack = drawer.takeItemsFromSlotWithDestroy(drawerIndex, subDrawer.getStoredItemStackSize());
|
||||
if (stack == null || stack.stackSize == 0) break;
|
||||
action.accept(stack);
|
||||
}
|
||||
|
||||
+88
-5
@@ -5,6 +5,7 @@ import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -14,6 +15,8 @@ import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@@ -39,6 +42,7 @@ import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.ILockable;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IProtectable;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.ISealable;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.LockAttribute;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.BlockDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.BlockDrawersCustom;
|
||||
import com.jaquadro.minecraft.storagedrawers.config.ConfigManager;
|
||||
import com.jaquadro.minecraft.storagedrawers.core.ModItems;
|
||||
@@ -48,6 +52,9 @@ import com.jaquadro.minecraft.storagedrawers.network.CountUpdateMessage;
|
||||
import com.jaquadro.minecraft.storagedrawers.storage.IUpgradeProvider;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.eventhandler.EventPriority;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import it.unimi.dsi.fastutil.ints.IntIterators;
|
||||
@@ -68,6 +75,10 @@ public abstract class TileEntityDrawers extends BaseTileEntity implements IDrawe
|
||||
private boolean hideUpgrade = false;
|
||||
private boolean downgraded = false;
|
||||
|
||||
private int ticksClickedInARow = 9;
|
||||
private int itemsOutputInARow = 0;
|
||||
private long lastLeftClickTime;
|
||||
|
||||
private UUID owner;
|
||||
private String securityKey;
|
||||
|
||||
@@ -86,6 +97,8 @@ public abstract class TileEntityDrawers extends BaseTileEntity implements IDrawe
|
||||
|
||||
protected TileEntityDrawers(int drawerCount) {
|
||||
initWithDrawerCount(drawerCount);
|
||||
TileEntityDrawersEvents eventHandler = new TileEntityDrawersEvents();
|
||||
MinecraftForge.EVENT_BUS.register(eventHandler);
|
||||
}
|
||||
|
||||
protected abstract IDrawer createDrawer(int slot);
|
||||
@@ -376,6 +389,38 @@ public abstract class TileEntityDrawers extends BaseTileEntity implements IDrawe
|
||||
downgraded = state;
|
||||
}
|
||||
|
||||
public void onClick(EntityPlayer player, int x, int y, int z, int face, World world, float hitX, float hitY,
|
||||
float hitZ, boolean invertShift) {
|
||||
BlockDrawers block = (BlockDrawers) world.getBlock(x, y, z);
|
||||
int dir = getDirection();
|
||||
if (dir == face) {
|
||||
int slot = block.getDrawerSlot(face, hitX, hitY, hitZ);
|
||||
IDrawer drawer = getDrawer(slot);
|
||||
if (drawer == null) return;
|
||||
final ItemStack item;
|
||||
// if invertSHift is true this will happen when the player is not shifting
|
||||
if (player.isSneaking() != invertShift) item = takeItemsFromSlot(slot, drawer.getStoredItemStackSize());
|
||||
else item = takeItemsFromSlot(slot, 1);
|
||||
|
||||
if (StorageDrawers.config.cache.debugTrace)
|
||||
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, (item == null) ? " null item" : " " + item);
|
||||
|
||||
if (item != null && item.stackSize > 0) {
|
||||
if (player.inventory.addItemStackToInventory(item)) {
|
||||
ForgeDirection dir2 = ForgeDirection.getOrientation(face);
|
||||
block.dropItemStack(world, x + dir2.offsetX, y, z + dir2.offsetZ, item);
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
} else world.playSoundEffect(
|
||||
x + .5f,
|
||||
y + .5f,
|
||||
z + .5f,
|
||||
"random.pop",
|
||||
.2f,
|
||||
((world.rand.nextFloat() - world.rand.nextFloat()) * .7f + 1) * 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isVoid() {
|
||||
if (!StorageDrawers.config.cache.enableVoidUpgrades) return false;
|
||||
|
||||
@@ -541,6 +586,24 @@ public abstract class TileEntityDrawers extends BaseTileEntity implements IDrawe
|
||||
ItemStack stack = getItemsFromSlot(slot, count);
|
||||
if (stack == null) return null;
|
||||
|
||||
if (worldObj.getTotalWorldTime() - lastLeftClickTime > 1) {
|
||||
ticksClickedInARow = 9;
|
||||
itemsOutputInARow = 0;
|
||||
} else {
|
||||
ticksClickedInARow++;
|
||||
}
|
||||
|
||||
lastLeftClickTime = worldObj.getTotalWorldTime();
|
||||
|
||||
Minecraft.getMinecraft().playerController.curBlockDamageMP = 0.0F;
|
||||
|
||||
int ticksConsecutiveClickRequirement = 50 / (itemsOutputInARow + 5);
|
||||
|
||||
if (ticksClickedInARow < ticksConsecutiveClickRequirement) return null;
|
||||
|
||||
ticksClickedInARow = 0;
|
||||
itemsOutputInARow++;
|
||||
|
||||
IDrawer drawer = drawers[slot];
|
||||
drawer.setStoredItemCount(drawer.getStoredItemCount() - stack.stackSize);
|
||||
|
||||
@@ -554,6 +617,23 @@ public abstract class TileEntityDrawers extends BaseTileEntity implements IDrawe
|
||||
return stack;
|
||||
}
|
||||
|
||||
public ItemStack takeItemsFromSlotWithDestroy(int slot, int count) {
|
||||
if (slot < 0 || slot >= getDrawerCount()) return null;
|
||||
|
||||
ItemStack stack = getItemsFromSlot(slot, count);
|
||||
if (stack == null) return null;
|
||||
|
||||
IDrawer drawer = drawers[slot];
|
||||
drawer.setStoredItemCount(drawer.getStoredItemCount() - stack.stackSize);
|
||||
|
||||
if (isRedstone() && worldObj != null) {
|
||||
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType());
|
||||
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord - 1, zCoord, getBlockType());
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an ItemStack that will have a maximum size of {@link ItemStack#getMaxStackSize()}
|
||||
*/
|
||||
@@ -780,11 +860,6 @@ public abstract class TileEntityDrawers extends BaseTileEntity implements IDrawe
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
inventory.markDirty();
|
||||
@@ -1098,4 +1173,12 @@ public abstract class TileEntityDrawers extends BaseTileEntity implements IDrawe
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class TileEntityDrawersEvents {
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.NORMAL)
|
||||
public void whenPlayerChangesDimension(PlayerEvent.PlayerChangedDimensionEvent event) {
|
||||
lastLeftClickTime = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.mixins;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.gtnewhorizon.gtnhmixins.IEarlyMixinLoader;
|
||||
import com.gtnewhorizon.gtnhmixins.builders.IMixins;
|
||||
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
|
||||
|
||||
@IFMLLoadingPlugin.MCVersion("1.7.10")
|
||||
public class EarlyMixinsLoader implements IFMLLoadingPlugin, IEarlyMixinLoader {
|
||||
|
||||
@Override
|
||||
public String[] getASMTransformerClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModContainerClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSetupClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectData(Map<String, Object> data) {}
|
||||
|
||||
@Override
|
||||
public String getAccessTransformerClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMixinConfig() {
|
||||
// rename the associated .json file by replacing the "mymodid" with your own mod ID
|
||||
// in the .json file edit the "package" and "refmap" properties to match your mod
|
||||
// also edit the "refmap" property in the "mixins.mymodid.json" file
|
||||
return "mixins.storagedrawers.early.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMixins(Set<String> loadedCoreMods) {
|
||||
return IMixins.getEarlyMixins(Mixins.class, loadedCoreMods);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.mixins;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.gtnewhorizon.gtnhmixins.builders.IMixins;
|
||||
import com.gtnewhorizon.gtnhmixins.builders.MixinBuilder;
|
||||
|
||||
public enum Mixins implements IMixins {
|
||||
|
||||
// Read the java doc of IMixins and MixinBuilder for further information
|
||||
|
||||
// You should declare all of your mixins early and late in this same enum
|
||||
|
||||
MIXIN_PLAYER_CONTROLLER(new MixinBuilder().setPhase(Phase.EARLY).addClientMixins("MixinPlayerControllerMP"));
|
||||
|
||||
private final MixinBuilder builder;
|
||||
|
||||
Mixins(MixinBuilder builder) {
|
||||
this.builder = builder;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public MixinBuilder getBuilder() {
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.mixins;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.gtnewhorizon.gtnhmixins.builders.ITargetMod;
|
||||
import com.gtnewhorizon.gtnhmixins.builders.TargetModBuilder;
|
||||
|
||||
public enum TargetMods implements ITargetMod {
|
||||
|
||||
// Read the java doc of ITargetMod and TargetModBuilder for further information
|
||||
|
||||
// Add to this enum information about the mods you need to identify during runtime
|
||||
|
||||
COFHCORE("cofh.asm.LoadingPlugin", "CoFHCore"),
|
||||
OPTIFINE("optifine.OptiFineForgeTweaker", "Optifine");
|
||||
|
||||
private final TargetModBuilder builder;
|
||||
|
||||
TargetMods(String coreModClass, String modId) {
|
||||
this.builder = new TargetModBuilder().setCoreModClass(coreModClass).setModId(modId);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public TargetModBuilder getBuilder() {
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.mixins.early;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.PlayerControllerMP;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.BlockDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.network.BlockClickMessage;
|
||||
|
||||
@Mixin(PlayerControllerMP.class)
|
||||
public abstract class MixinPlayerControllerMP {
|
||||
|
||||
@Shadow
|
||||
private Minecraft mc;
|
||||
|
||||
@Inject(
|
||||
method = "onPlayerDamageBlock",
|
||||
at = @At(
|
||||
value = "INVOKE_ASSIGN",
|
||||
target = "Lnet/minecraft/block/Block;getPlayerRelativeBlockHardness(Lnet/minecraft/entity/player/EntityPlayer;Lnet/minecraft/world/World;III)F"))
|
||||
private void mixin(int x, int y, int z, int side, CallbackInfo ci) {
|
||||
if (mc.theWorld.getTileEntity(x, y, z) instanceof TileEntityDrawers ted
|
||||
&& mc.theWorld.getBlock(x, y, z) instanceof BlockDrawers bd) {
|
||||
if (ted.getDirection() == side) {
|
||||
final int reach = 5;
|
||||
double eyeX = mc.thePlayer.posX;
|
||||
double eyeY = mc.thePlayer.posY + mc.thePlayer.getEyeHeight();
|
||||
double eyeZ = mc.thePlayer.posZ;
|
||||
|
||||
Vec3 look = mc.thePlayer.getLookVec();
|
||||
|
||||
Vec3 end = Vec3.createVectorHelper(
|
||||
eyeX + look.xCoord * reach,
|
||||
eyeY + look.yCoord * reach,
|
||||
eyeZ + look.zCoord * reach);
|
||||
|
||||
MovingObjectPosition mop = mc.theWorld.rayTraceBlocks(Vec3.createVectorHelper(eyeX, eyeY, eyeZ), end);
|
||||
float hitX = (float) (mop.hitVec.xCoord - mop.blockX);
|
||||
float hitY = (float) (mop.hitVec.yCoord - mop.blockY);
|
||||
float hitZ = (float) (mop.hitVec.zCoord - mop.blockZ);
|
||||
boolean invertShift = StorageDrawers.config.cache.invertShift;
|
||||
StorageDrawers.network
|
||||
.sendToServer(new BlockClickMessage(x, y, z, side, hitX, hitY, hitZ, invertShift));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
public net.minecraft.client.multiplayer.PlayerControllerMP field_78770_f
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8.5-GTNH",
|
||||
"refmap": "mixins.storagedrawers.refmap.json",
|
||||
"target": "@env(DEFAULT)",
|
||||
"compatibilityLevel": "JAVA_8"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8.5-GTNH",
|
||||
"package": "com.jaquadro.minecraft.storagedrawers.mixins.early",
|
||||
"refmap": "mixins.storagedrawers.refmap.json",
|
||||
"target": "@env(DEFAULT)",
|
||||
"compatibilityLevel": "JAVA_8"
|
||||
}
|
||||
Reference in new issue
Block a user