Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/main/java/jss/bugtorch/BugTorch.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@

import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import cpw.mods.fml.relauncher.Side;
import glowredman.txloader.TXLoaderCore;
import glowredman.txloader.Asset.Source;
import jss.bugtorch.listeners.ButtonManager;
import jss.bugtorch.listeners.DropHandler;
import jss.bugtorch.listeners.PacketSwingArm;
import jss.bugtorch.mixinplugin.BugTorchEarlyMixins;
import jss.bugtorch.modsupport.ExtraUtilitiesSupport;
import jss.bugtorch.modsupport.PamsTemperatePlantsSupport;
Expand Down Expand Up @@ -41,7 +46,7 @@ public class BugTorch {
public static final Logger logger = LogManager.getLogger(NAME);
// cached to boost looping, should be used pretty often due to how recipe lookup works
public static final int[] dyeOreIds = new int[16];

public BugTorch() {
String configFolder = Loader.instance().getConfigDir().getAbsolutePath() + File.separator + MODID + File.separator;
BugTorchConfig.loadBaseConfig(new File(configFolder + "base.cfg"));
Expand Down Expand Up @@ -70,6 +75,17 @@ public void preInit(FMLPreInitializationEvent event) {
}
}

public static SimpleNetworkWrapper networkWrapper;

@Mod.EventHandler
public void init(FMLInitializationEvent event) {
FMLCommonHandler.instance().bus().register(DropHandler.INSTANCE);
MinecraftForge.EVENT_BUS.register(DropHandler.INSTANCE);

networkWrapper = NetworkRegistry.INSTANCE.newSimpleChannel(BugTorch.MODID);
networkWrapper.registerMessage(PacketSwingArm.class, PacketSwingArm.class, 0, Side.CLIENT);
}

@Mod.EventHandler
public void postInit(FMLPostInitializationEvent event) {
String[] dyes = {
Expand Down
17 changes: 16 additions & 1 deletion src/main/java/jss/bugtorch/config/BugTorchConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ public class BugTorchConfig {
public static int showBroadcastSettingsButton;
public static int showOpenToLanButton;
public static int showSuperSecretSettingsButton;
public static boolean replaceItemTossDropAnimation;

//Mod bugfixes
public static boolean fixExtraUtilitiesBlockSounds;
public static boolean fixPamsTemperatePlantsBlockSounds;
public static boolean fixWitcheryBlockSounds;
public static boolean fixWitcheryBlockLighting;

//Mod ore dictionary
public static boolean registerThaumcraftLeavesToTheOreDictionary;
Expand Down Expand Up @@ -70,6 +72,11 @@ public class BugTorchConfig {
public static boolean fixVillagerTradeMetadataDetection;
public static boolean fixVillageSieges;
public static boolean fixVillageWellDesertMaterial;
public static boolean fixItemBouncingBlock;
public static boolean fixBlockFenceAnim;
public static boolean fixRedstoneWireBlockBounds;
public static boolean fixItemRedstoneAnim;
public static boolean fixItemSlabAnim;

//Mixin performance improvements
public static boolean brokenChestsDontSplitStacks;
Expand Down Expand Up @@ -166,6 +173,7 @@ public static void loadBaseConfig(File configFile) {
showBroadcastSettingsButton = config.getInt("showBroadcastSettingsButton", categoryTweaks, 1, -1, 1, "Show (1), disable(0), or remove(-1) the Broadcast Settings button in the options menu.");
showOpenToLanButton = config.getInt("showOpenToLanButton", categoryTweaks, 1, -1, 1, "Show (1), disable(0), or remove(-1) the Open to LAN button in the escape menu.");
showSuperSecretSettingsButton = config.getInt("showSuperSecretSettingsButton", categoryTweaks, 1, -1, 1, "Show (1), disable(0), or remove(-1) the Super Secret Settings button in the options menu.");
replaceItemTossDropAnimation = config.getBoolean("replaceItemTossDropAnimation", categoryTweaks, true, "Backport hand swinging when dropping items.");

//Update old config options
if(config.hasKey(categoryTweaks, "removeBroadcastSettingsButton")) {
Expand All @@ -187,6 +195,7 @@ public static void loadModdedConfig(File configFile) {
fixExtraUtilitiesBlockSounds = config.getBoolean("fixExtraUtilitiesBlockSounds", categoryBugfixes, true, "Assigns the correct sound types to some blocks from Extra Utilities.");
fixPamsTemperatePlantsBlockSounds = config.getBoolean("fixPamsTemperatePlantsBlockSounds", categoryBugfixes, true, "Assigns the correct sound types to some blocks from Pam's Temperate Plants.");
fixWitcheryBlockSounds = config.getBoolean("fixWitcheryBlockSounds", categoryBugfixes, true, "Assigns the correct sound types to some blocks from Witchery.");
fixWitcheryBlockLighting = config.getBoolean("fixWitcheryBlockLighting", categoryBugfixes, true, "Fixes stairs and slabs having dark lighting.");

//Ore dictionary
registerThaumcraftLeavesToTheOreDictionary = config.getBoolean("registerThaumcraftLeavesToTheOreDictionary", categoryOreDictionary, true, "Register Thaumcraft Greatwood and Silverwood leaves as treeLeaves.");
Expand Down Expand Up @@ -238,7 +247,13 @@ public static void loadBaseMixinConfig(File configFile) {
fixVillagerTradeMetadataDetection = false; config.getBoolean("fixVillagerTradeMetadataDetection", categoryBugfixes, true, "Villager trades will respect metadata.\nCurrently unfinished and disabled internally.\nFrom MC 1.8");
fixVillageSieges = config.getBoolean("fixVillageSieges", categoryBugfixes, true, "Zombies will siege villages that are large enough at night.\nFrom MC 1.8, fixes MC-7432 and MC-7488");
fixVillageWellDesertMaterial = config.getBoolean("fixVillageWellDesertMaterial", categoryBugfixes, true, "Wells in desert villages will use the correct material.\nFrom MC 1.8, fixes MC-32514");
fixLWJGL2OpenALCrash = config.getBoolean("fixLWJGL2OpenALCrash", categoryBugfixes, true, "Fixes the ridiculous bug where the SoundSystem will consistently fail to re/initialize, commonly observed with LWJGL2 nightlies on Linux. Disabled when LWJGL3ify is present.");
fixItemBouncingBlock = config.getBoolean("fixItemBouncingBlock", categoryBugfixes, true, "Fixes items bouncing on blocks with complicated block bounds like stairs, cauldron and hoppers.");
fixBlockFenceAnim = config.getBoolean("fixBlockFenceAnim", categoryBugfixes, true, "Fixes right click animation triggering when right clicking a fence even if nothing happens.");
fixRedstoneWireBlockBounds = config.getBoolean("fixRedstoneWireBlockBounds", categoryBugfixes, true, "Fix redstone wires having inaccurate block bounds.");
fixItemRedstoneAnim = config.getBoolean("fixItemRedstoneAnim", categoryBugfixes, true, "Fixes right click animation triggering when right clicking a redstone dust even if nothing happens.");
fixItemSlabAnim = config.getBoolean("fixItemSlabAnim", categoryBugfixes, true, "Fixes right click animation triggering when right clicking a slab even if nothing happens.");

fixLWJGL2OpenALCrash = config.getBoolean("fixLWJGL2OpenALCrash", categoryBugfixes, true, "Fixes the ridiculous bug where the SoundSystem will consistently fail to re/initialize, commonly observed with LWJGL2 nightlies on Linux. Disabled when LWJGL3ify is present.");

//Performance
brokenChestsDontSplitStacks = config.getBoolean("brokenChestsDontSplitStacks", categoryPerformance, false, "Broken chests don't split apart dropped item stacks.");
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/jss/bugtorch/listeners/DropHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package jss.bugtorch.listeners;

import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import jss.bugtorch.config.BugTorchConfig;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import jss.bugtorch.BugTorch;
import net.minecraftforge.event.entity.item.ItemTossEvent;

public class DropHandler {
public static final DropHandler INSTANCE = new DropHandler();

@SubscribeEvent(priority = EventPriority.HIGHEST)
public void tossItem(ItemTossEvent event) {
EntityPlayer player = event.player;

if (!player.worldObj.isRemote && BugTorchConfig.replaceItemTossDropAnimation) {
EntityPlayerMP playerMP = (EntityPlayerMP) player;
BugTorch.networkWrapper.sendTo(new PacketSwingArm(player), playerMP);
}
}
}
38 changes: 38 additions & 0 deletions src/main/java/jss/bugtorch/listeners/PacketSwingArm.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package jss.bugtorch.listeners;

import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;

public class PacketSwingArm implements IMessage, IMessageHandler<PacketSwingArm, IMessage> {

private int playerEntityId;

public PacketSwingArm() { }

public PacketSwingArm(EntityPlayer player) {
this.playerEntityId = player.getEntityId();
}

@Override
public void fromBytes(ByteBuf buf) {
this.playerEntityId = buf.readInt();
}

@Override
public void toBytes(ByteBuf buf) {
buf.writeInt(this.playerEntityId);
}

@Override
public IMessage onMessage(PacketSwingArm message, MessageContext ctx) {
EntityPlayer player = (EntityPlayer) Minecraft.getMinecraft().theWorld.getEntityByID(message.playerEntityId);
if (player != null) {
player.swingItem();
}
return null;
}
}
15 changes: 15 additions & 0 deletions src/main/java/jss/bugtorch/mixinplugin/BugTorchEarlyMixins.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@ public List<String> getMixins(Set<String> loadedCoreMods) {
if(BugTorchConfig.throwEnderPearlsInCreativeMode) {
mixins.add("minecraft.backport.MixinItemEnderPearl");
}
if(BugTorchConfig.fixItemBouncingBlock) {
mixins.add("minecraft.fix.MixinEntity_FixItemBouncingBlock");
}
if(client && BugTorchConfig.fixBlockFenceAnim) {
mixins.add("minecraft.fix.MixinBlockFence");
}
if(BugTorchConfig.fixRedstoneWireBlockBounds) {
mixins.add("minecraft.fix.MixinBlockRedstoneWire");
}
if(client && BugTorchConfig.fixItemRedstoneAnim) {
mixins.add("minecraft.fix.MixinItemRedstone");
}
if(client && BugTorchConfig.fixItemSlabAnim) {
mixins.add("minecraft.fix.MixinItemSlab");
}

//Bugfixes
if(client && BugTorchConfig.fixAnvilSoundTypeStepSound) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package jss.bugtorch.mixins.early.minecraft.fix;

import net.minecraft.block.BlockFence;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemLead;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;

@Mixin(BlockFence.class)
public class MixinBlockFence {

@Overwrite
public boolean onBlockActivated(World worldIn, int x, int y, int z, EntityPlayer player, int side, float subX, float subY, float subZ)
{
if(!worldIn.isRemote) {
return ItemLead.func_150909_a(player, worldIn, x, y, z);
}
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package jss.bugtorch.mixins.early.minecraft.fix;

import net.minecraft.block.Block;
import net.minecraft.block.BlockRedstoneWire;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

import java.util.List;

@Mixin(BlockRedstoneWire.class)
public abstract class MixinBlockRedstoneWire extends Block {

protected MixinBlockRedstoneWire(Material material) {
super(material);
}

/**
* @author John
* @reason Make Block Bounds of Redstone more accurate depending on state.
*/
public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int x, int y, int z)
{
boolean flag = BlockRedstoneWire.isPowerProviderOrWire(blockAccess, x - 1, y, z, 1) || !blockAccess.getBlock(x - 1, y, z).isBlockNormalCube() && BlockRedstoneWire.isPowerProviderOrWire(blockAccess, x - 1, y - 1, z, -1);
boolean flag1 = BlockRedstoneWire.isPowerProviderOrWire(blockAccess, x + 1, y, z, 3) || !blockAccess.getBlock(x + 1, y, z).isBlockNormalCube() && BlockRedstoneWire.isPowerProviderOrWire(blockAccess, x + 1, y - 1, z, -1);
boolean flag2 = BlockRedstoneWire.isPowerProviderOrWire(blockAccess, x, y, z - 1, 2) || !blockAccess.getBlock(x, y, z - 1).isBlockNormalCube() && BlockRedstoneWire.isPowerProviderOrWire(blockAccess, x, y - 1, z - 1, -1);
boolean flag3 = BlockRedstoneWire.isPowerProviderOrWire(blockAccess, x, y, z + 1, 0) || !blockAccess.getBlock(x, y, z + 1).isBlockNormalCube() && BlockRedstoneWire.isPowerProviderOrWire(blockAccess, x, y - 1, z + 1, -1);

if (!blockAccess.getBlock(x, y + 1, z).isBlockNormalCube())
{
if (blockAccess.getBlock(x - 1, y, z).isBlockNormalCube() && BlockRedstoneWire.isPowerProviderOrWire(blockAccess, x - 1, y + 1, z, -1))
{
flag = true;
}

if (blockAccess.getBlock(x + 1, y, z).isBlockNormalCube() && BlockRedstoneWire.isPowerProviderOrWire(blockAccess, x + 1, y + 1, z, -1))
{
flag1 = true;
}

if (blockAccess.getBlock(x, y, z - 1).isBlockNormalCube() && BlockRedstoneWire.isPowerProviderOrWire(blockAccess, x, y + 1, z - 1, -1))
{
flag2 = true;
}

if (blockAccess.getBlock(x, y, z + 1).isBlockNormalCube() && BlockRedstoneWire.isPowerProviderOrWire(blockAccess, x, y + 1, z + 1, -1))
{
flag3 = true;
}
}

float gap = 0.2F;
float gap2 = gap;
float gap3 = gap;
float gap4 = gap2;
if(flag) {
gap = 0.0F;
}
if(flag1) {
gap2 = 0.0F;
}
if(flag2) {
gap3 = 0.0F;
}
if(flag3) {
gap4 = 0.0F;
}
if((flag || flag1) && !flag2 && !flag3) {
gap = 0.0F;
gap2 = 0.0F;
}
if((flag2 || flag3) && !flag && !flag1) {
gap3 = 0.0F;
gap4 = 0.0F;
}
this.setBlockBounds(gap, 0.0F, gap3, 1 - gap2, 0.0625F, 1 - gap4);

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package jss.bugtorch.mixins.early.minecraft.fix;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(Entity.class)
public class MixinEntity_FixItemBouncingBlock {
/**
* @author Myask-sl
* @reason make items not bounce on stairs/cauldrons/etc. whose selection boxes are full, but collisions aren't
* @param original o.return: whether the block has average selection bound box length >= 1
* @return adjustment to ignore this for items
*/
@ModifyExpressionValue(method = "func_145771_j",
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;func_147469_q(III)Z", ordinal = 0))
private boolean dontEjectBySelectionBox(boolean original) {
return original && !(((Object)this) instanceof EntityItem);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package jss.bugtorch.mixins.early.minecraft.fix;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemRedstone;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;

@Mixin(ItemRedstone.class)
public class MixinItemRedstone {

/**
* @author John
* @reason Fix Redstone Wire Ghost Right Click
*/
@Overwrite
public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_)
{
if (p_77648_3_.getBlock(p_77648_4_, p_77648_5_, p_77648_6_) != Blocks.snow_layer)
{
if (p_77648_7_ == 0)
{
--p_77648_5_;
}

if (p_77648_7_ == 1)
{
++p_77648_5_;
}

if (p_77648_7_ == 2)
{
--p_77648_6_;
}

if (p_77648_7_ == 3)
{
++p_77648_6_;
}

if (p_77648_7_ == 4)
{
--p_77648_4_;
}

if (p_77648_7_ == 5)
{
++p_77648_4_;
}

if (!p_77648_3_.isAirBlock(p_77648_4_, p_77648_5_, p_77648_6_))
{
return false;
}
}

if (!p_77648_2_.canPlayerEdit(p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_1_))
{
return false;
}
else
{
if (Blocks.redstone_wire.canPlaceBlockAt(p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_))
{
--p_77648_1_.stackSize;
p_77648_3_.setBlock(p_77648_4_, p_77648_5_, p_77648_6_, Blocks.redstone_wire);
return true;
}
}
return false;
}
}
Loading