-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6acdcd3
commit 45e354f
Showing
17 changed files
with
167 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/net/aspw/client/injection/forge/mixins/block/MixinWorld.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package net.aspw.client.injection.forge.mixins.block; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.block.material.Material; | ||
import net.minecraft.block.state.IBlockState; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.init.Blocks; | ||
import net.minecraft.util.BlockPos; | ||
import net.minecraft.world.IBlockAccess; | ||
import net.minecraft.world.World; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Overwrite; | ||
|
||
@Mixin(World.class) | ||
public abstract class MixinWorld implements IBlockAccess { | ||
|
||
/** | ||
* @author As_pw | ||
* @reason Fix Destroy Sounds | ||
*/ | ||
@Overwrite | ||
public boolean destroyBlock(BlockPos pos, boolean dropBlock) { | ||
IBlockState iblockstate = Minecraft.getMinecraft().theWorld.getBlockState(pos); | ||
Block block = iblockstate.getBlock(); | ||
|
||
// Moving playAusSFX out of else-statement to play sound correctly (For some reason block.getMaterial() always returns Material.air on 1.9+ protocols) | ||
// This should also function correctly on 1.8.x protocol, so no need for base version checks | ||
Minecraft.getMinecraft().theWorld.playAuxSFX(2001, pos, Block.getStateId(iblockstate)); | ||
|
||
if (block.getMaterial() == Material.air) { | ||
return false; | ||
} else { | ||
if (dropBlock) { | ||
block.dropBlockAsItem(Minecraft.getMinecraft().theWorld, pos, iblockstate, 0); | ||
} | ||
|
||
return Minecraft.getMinecraft().theWorld.setBlockState(pos, Blocks.air.getDefaultState(), 3); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/main/java/net/aspw/client/injection/forge/mixins/item/MixinItemBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package net.aspw.client.injection.forge.mixins.item; | ||
|
||
import net.aspw.client.protocol.Protocol; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.block.state.IBlockState; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.entity.Entity; | ||
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.BlockPos; | ||
import net.minecraft.util.EnumFacing; | ||
import net.minecraft.world.World; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Overwrite; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
|
||
@Mixin(ItemBlock.class) | ||
public class MixinItemBlock extends Item { | ||
|
||
@Shadow | ||
@Final | ||
public Block block; | ||
|
||
/** | ||
* @author As_pw | ||
* @reason Fix Block Sounds | ||
*/ | ||
@Overwrite | ||
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { | ||
IBlockState iblockstate = worldIn.getBlockState(pos); | ||
Block block = iblockstate.getBlock(); | ||
|
||
if (!block.isReplaceable(worldIn, pos)) { | ||
pos = pos.offset(side); | ||
} | ||
|
||
if (stack.stackSize == 0) { | ||
return false; | ||
} else if (!playerIn.canPlayerEdit(pos, side, stack)) { | ||
return false; | ||
} else if (worldIn.canBlockBePlaced(this.block, pos, false, side, null, stack)) { | ||
int i = this.getMetadata(stack.getMetadata()); | ||
IBlockState iblockstate1 = this.block.onBlockPlaced(worldIn, pos, side, hitX, hitY, hitZ, i, playerIn); | ||
|
||
if (worldIn.setBlockState(pos, iblockstate1, 3)) { | ||
iblockstate1 = worldIn.getBlockState(pos); | ||
|
||
if (iblockstate1.getBlock() == this.block) { | ||
ItemBlock.setTileEntityNBT(worldIn, playerIn, pos, stack); | ||
this.block.onBlockPlacedBy(worldIn, pos, iblockstate1, playerIn, stack); | ||
} | ||
|
||
if (!Protocol.versionSlider.getSliderVersion().getName().equals("1.8.x")) { | ||
// Using playSoundAtPos instead of playSoundEffect (I have no understanding as to why playSoundEffect is not functioning properly on 1.9+ protocols) | ||
Minecraft.getMinecraft().theWorld.playSoundAtPos(pos.add(0.5, 0.5, 0.5), this.block.stepSound.getPlaceSound(), (this.block.stepSound.getVolume() + 1.0F) / 2.0F, this.block.stepSound.getFrequency() * 0.8F, false); | ||
} else { | ||
worldIn.playSoundEffect((float) pos.getX() + 0.5F, (float) pos.getY() + 0.5F, (float) pos.getZ() + 0.5F, this.block.stepSound.getPlaceSound(), (this.block.stepSound.getVolume() + 1.0F) / 2.0F, this.block.stepSound.getFrequency() * 0.8F); | ||
} | ||
|
||
--stack.stackSize; | ||
} | ||
|
||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
} |
Oops, something went wrong.