Skip to content

Commit

Permalink
Honey fixes, add honeycomb block, add mixin throwable collide mixin
Browse files Browse the repository at this point in the history
Honey blocks now are sticky and prevent fully jumping
Fix random BlockSoulSand debug code in honey blocks (I was legit too lazy to scroll through the classes so I just wrote that as a shortcut to get to soul sand's class lol)
Update honey bottle texture to use old style bottles
Fix target blocks not working
Fix erroneous config values for bee stuff
  • Loading branch information
Roadhog360 committed Aug 17, 2023
1 parent ac94fb8 commit 5533a34
Show file tree
Hide file tree
Showing 12 changed files with 132 additions and 75 deletions.
12 changes: 8 additions & 4 deletions src/main/java/ganymedes01/etfuturum/EtFuturumMixinPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,19 @@ public List<String> getMixins() {
mixins.add("observer.MixinChunk");
}

if(ConfigMixins.arrowFallingFix) {
if (ConfigMixins.arrowFallingFix) {
mixins.add("fallingarrowfix.MixinEntityArrow");
}

if(ConfigMixins.blockHopperInteraction) {
if (ConfigMixins.blockHopperInteraction) {
mixins.add("blockinventories.MixinTileEntityHopper");
}

if(side == MixinEnvironment.Side.CLIENT) {

if (ConfigMixins.collidedThrowableFix) {
mixins.add("projectilecollidefix.MixinEntityThrowable");
}

if (side == MixinEnvironment.Side.CLIENT) {
if (ConfigMixins.dustUnderFallingBlocks) {
mixins.add("blockfallingparticles.MixinBlockFalling");
}
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/ganymedes01/etfuturum/ModBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,11 @@ public enum ModBlocks {
DRIPSTONE_BLOCK(EtFuturum.TESTING, new BaseBlock(Material.rock).setNames("dripstone_block")
.setBlockSound(ModSounds.soundDripstoneBlock).setHardness(1.5F).setResistance(1F)),
POINTED_DRIPSTONE(EtFuturum.TESTING, new BlockPointedDripstone()),
HONEY_BLOCK(EtFuturum.TESTING, new BlockHoney()),
BEEHIVE(EtFuturum.TESTING, new BlockBeeHive().setHiveType("beehive", true)),
BEE_NEST(EtFuturum.TESTING, new BlockBeeHive().setHiveType("bee_nest", true)),
HONEY_BLOCK(ConfigEntities.enableBees, new BlockHoney()),
HONEYCOMB_BLOCK(ConfigEntities.enableBees, new BaseBlock(Material.clay).setNames("honeycomb_block")
.setBlockSound(ModSounds.soundCoralBlock).setHardness(0.6F).setResistance(0.6F)),
BEEHIVE(ConfigEntities.enableBees, new BlockBeeHive().setHiveType("beehive", true)),
BEE_NEST(ConfigEntities.enableBees, new BlockBeeHive().setHiveType("bee_nest", true)),

//signs
SIGN_SPRUCE(ConfigBlocksItems.enableSigns, new BlockWoodSign(TileEntityWoodSign.class, true, 1), null),
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/ganymedes01/etfuturum/ModItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public enum ModItems {
OTHERSIDE_RECORD(ConfigBlocksItems.enableOtherside, new ItemEtFuturumRecord("otherside")),
AMETHYST_SHARD(ConfigBlocksItems.enableAmethyst, new BaseItem("amethyst_shard")),
SHULKER_BOX_UPGRADE(EtFuturum.hasIronChest && ConfigModCompat.shulkerBoxesIronChest, new ItemShulkerBoxUpgrade()),
HONEYCOMB(ConfigBlocksItems.enableAmethyst, new BaseItem("honeycomb")),
HONEY_BOTTLE(ConfigBlocksItems.enableAmethyst, new ItemHoneyBottle()),
HONEYCOMB(ConfigEntities.enableBees, new BaseItem("honeycomb")),
HONEY_BOTTLE(ConfigEntities.enableBees, new ItemHoneyBottle()),

ITEM_SIGN_SPRUCE(ConfigBlocksItems.enableSigns, new ItemWoodSign(1)),
ITEM_SIGN_BIRCH(ConfigBlocksItems.enableSigns, new ItemWoodSign(2)),
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/ganymedes01/etfuturum/blocks/BlockHoney.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import ganymedes01.etfuturum.lib.Reference;
import ganymedes01.etfuturum.lib.RenderIDs;
import net.minecraft.block.Block;
import net.minecraft.block.BlockSoulSand;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
Expand All @@ -31,13 +30,13 @@ public BlockHoney() {
super(Material.clay);
setNames("honey_block");
setBlockSound(ModSounds.soundHoneyBlock);
BlockSoulSand.getBlockFromItem(null);
}

/**
* TODO
* showJumpParticles and showSlideParticles use a packet in modern. I really don't see any reason to implement a packet for this.
* That's why watching other entities slide on honey won't have particles.
* That's why watching other entities slide on honey won't have particles. Keeping this here for reference.
* Also items often fall off of the honey block on the clientside
*/


Expand Down
28 changes: 19 additions & 9 deletions src/main/java/ganymedes01/etfuturum/blocks/BlockTarget.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public class BlockTarget extends BaseBlock {
public BlockTarget() {
super(Material.grass);
setNames("target");
setStepSound(soundTypeGrass);
setHardness(0.5F);
setResistance(0.5F);
setStepSound(soundTypeGrass);
HoeRegistry.addToHoeArray(this);
}

Expand Down Expand Up @@ -97,23 +97,33 @@ public boolean canProvidePower() {
return true;
}

/**
* For some reason, returning FALSE will do the power updates??
* This function should be named shouldNOTCheckPower?!
*/
public boolean shouldCheckWeakPower(IBlockAccess world, int x, int y, int z, int side) {
return false;
}

@Override
public int isProvidingStrongPower(IBlockAccess p_149748_1_, int p_149748_2_, int p_149748_3_, int p_149748_4_, int p_149748_5_) {
return isProvidingWeakPower(p_149748_1_, p_149748_2_, p_149748_3_, p_149748_4_, p_149748_5_);
public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int meta) {
return isProvidingWeakPower(world, x, y, z, meta);
}

@Override
public int isProvidingWeakPower(IBlockAccess p_149709_1_, int p_149709_2_, int p_149709_3_, int p_149709_4_, int p_149709_5_) {
return p_149709_1_.getBlockMetadata(p_149709_2_, p_149709_3_, p_149709_4_);
public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int meta) {
return world.getBlockMetadata(x, y, z);
}

public boolean isNormalCube(IBlockAccess world, int x, int y, int z) {
return true;
}

public boolean isNormalCube(IBlockAccess world, int x, int y, int z)
{
public boolean isNormalCube() {
return true;
}

public boolean isNormalCube()
{
public boolean isOpaqueCube() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public String getStepResourcePath() {
public static final SoundType soundPointedDripstone = new CustomSound("pointed_dripstone");
public static final SoundType soundWetGrass = new CustomSound("wet_grass", true).setDisabledSound(Block.soundTypeGrass);
public static final SoundType soundHoneyBlock = new CustomSound("honey_block").setDisabledSound(soundSlime);
public static final SoundType soundCoralBlock = new CustomSound("coral_block").setDisabledSound(soundSlime);
// public static final SoundType soundNylium = new CustomSound("nylium");
// public static final SoundType soundHoneyBlock = new CustomSound("honey_block");
//public static final SoundType soundShroomlight = new CustomSound("shroomlight");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class ConfigMixins extends ConfigBase {
public static boolean arrowFallingFix;
public static boolean adjustedAttenuation;
public static boolean dustUnderFallingBlocks;
public static boolean collidedThrowableFix;

public ConfigMixins(File file) {
super(file);
Expand Down Expand Up @@ -85,6 +86,7 @@ protected void syncConfigOptions() {

stepHeightFix = getBoolean("stepHeightFix", catFixes, true, "Makes the player able to step up even if a block would be above their head at the destination.\nModified classes: net.minecraft.entity.Entity");
arrowFallingFix = getBoolean("arrowFallingFix", catFixes, true, "Prevents arrows from falling off of blocks too easily\nModified classes: net.minecraft.entity.EntityArrow");
collidedThrowableFix = getBoolean("collidedThrowableFix", catFixes, true, "Fixes EntityThrowable entities not calling onEntityCollidedWithBlock, causing them to not trigger target blocks or chime amethyst.\nModified classes: net.minecraft.entity.projectile.EntityThrowable");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import ganymedes01.etfuturum.configuration.configs.ConfigSounds;
import ganymedes01.etfuturum.elytra.IElytraPlayer;
import ganymedes01.etfuturum.entities.EntityNewBoatWithChest;
import ganymedes01.etfuturum.items.ItemHoneyBottle;
import ganymedes01.etfuturum.lib.Reference;
import ganymedes01.etfuturum.network.ChestBoatOpenInventoryMessage;
import ganymedes01.etfuturum.tileentities.TileEntityShulkerBox;
Expand Down Expand Up @@ -499,6 +500,8 @@ public void onPlaySoundAtEntityEvent(PlaySoundAtEntityEvent event) {
* We have to do this because we don't want our new sound to be caught in the below logic, and get freeze in a loop of repeatedly replacing itself and firing events forever.
* And no, unlike the regular play sound event, the result isn't a PositionedSoundRecord so we can't just supply a new one in the result. We can only override the name.
* Because SOMEONE THOUGHT IT WOULD BE A GOOD IDEA TO MAKE IT SO YOU CAN ONLY CHANGE THE EVENT NAME AND NOT VOLUME OR PITCH???
* So as a solution I need to play a new sound instead of modifying the event one, and I do this to "mark" the sound, making sure it doesn't get run through this logic.
* Then we strip the ignore suffix and skip the custom sound logic. I don't like the way this works either but I don't think I have a choice lol, blame Forge
*/
if (event.name.endsWith(ignore_suffix)) {
event.name = event.name.replace(ignore_suffix, "");
Expand All @@ -514,60 +517,67 @@ public void onPlaySoundAtEntityEvent(PlaySoundAtEntityEvent event) {
return;//This is the only code I want to run if !isRemote
}

if (event.entity instanceof EntityPlayer && event.name.equals("random.drink")) {
EntityPlayer player = (EntityPlayer) event.entity;
if (player.isUsingItem() && player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemHoneyBottle) {
event.entity.playSound(Reference.MCAssetVer + ":item.honey_bottle.drink" + ignore_suffix, 1, 1);
event.setCanceled(true);
return;
}
}

// --- Player Splash --- //
if (ConfigSounds.heavyWaterSplashing && event.name.equals("game.player.swim.splash"))
{
if (ConfigSounds.heavyWaterSplashing && event.name.equals("game.player.swim.splash")) {

// Water-striking speed to determine whether to play the large splash sound
float doWaterSplashEffect_f1 = (MathHelper.sqrt_double(entity.motionX * entity.motionX * 0.20000000298023224D + entity.motionY * entity.motionY + entity.motionZ * entity.motionZ * 0.20000000298023224D)) * (entity.riddenByEntity==null ? 0.2F : 0.9F);
float doWaterSplashEffect_f1 = (MathHelper.sqrt_double(entity.motionX * entity.motionX * 0.20000000298023224D + entity.motionY * entity.motionY + entity.motionZ * entity.motionZ * 0.20000000298023224D)) * (entity.riddenByEntity == null ? 0.2F : 0.9F);

if (doWaterSplashEffect_f1 > 1.0F) {doWaterSplashEffect_f1 = 1.0F;}
if (doWaterSplashEffect_f1 > 1.0F) {
doWaterSplashEffect_f1 = 1.0F;
}

// Play fast splash sound instead
if (doWaterSplashEffect_f1 >= 0.25D)
{
event.name = Reference.MCAssetVer+":entity.player.splash.high_speed";
if (doWaterSplashEffect_f1 >= 0.25D) {
event.name = Reference.MCAssetVer + ":entity.player.splash.high_speed";
return;
}
}

if(event.name != null) {
int x = MathHelper.floor_double(event.entity.posX);
int y = MathHelper.floor_double(event.entity.posY - 0.20000000298023224D - event.entity.yOffset);
int z = MathHelper.floor_double(event.entity.posZ);
World world = FMLClientHandler.instance().getWorldClient();
Block block = world.getBlock(x, y, z);

if (MultiBlockSoundRegistry.multiBlockSounds.containsKey(block) && block.stepSound.getStepResourcePath().equals(event.name)) {
MultiBlockSoundContainer obj = MultiBlockSoundRegistry.multiBlockSounds.get(block);
String newSoundString = obj.getSound(world, x, y, z, event.name, MultiBlockSoundRegistry.BlockSoundType.WALK);
float volume = obj.getVolume(world, x, y, z, event.volume, MultiBlockSoundRegistry.BlockSoundType.WALK);
float pitch = obj.getPitch(world, x, y, z, event.volume, MultiBlockSoundRegistry.BlockSoundType.WALK);
if (newSoundString != null || volume != -1 || pitch != -1) {
if (newSoundString == null) newSoundString = event.name;
if (volume == -1) volume = event.volume;
if (pitch == -1) pitch = event.pitch;
event.entity.playSound(newSoundString + ignore_suffix, volume, pitch);
event.setCanceled(true);
}
} else if (ConfigSounds.newBlockSounds && ModSounds.soundAmethystBlock.getStepResourcePath().equals(event.name)) {
MutablePair<Float, Integer> pair = AMETHYST_CHIME_CACHE.get(event.entity);
if (pair == null) {
pair = new MutablePair<>(0.0F, 0);
}
float field_26997 = pair.getLeft();
int lastChimeAge = pair.getRight();
if (event.entity.ticksExisted >= lastChimeAge + 20) {
field_26997 = (float) ((double) field_26997 * Math.pow(0.996999979019165D, (double) (event.entity.ticksExisted - lastChimeAge)));
field_26997 = Math.min(1.0F, field_26997 + 0.07F);
float f = 0.5F + field_26997 * event.entity.worldObj.rand.nextFloat() * 1.2F;
float g = 0.1F + field_26997 * 1.2F;
event.entity.playSound(Reference.MCAssetVer + ":block.amethyst_block.chime", g, f);
lastChimeAge = event.entity.ticksExisted;
pair.setLeft(field_26997);
pair.setRight(lastChimeAge);
AMETHYST_CHIME_CACHE.put(event.entity, pair);
}
int x = MathHelper.floor_double(event.entity.posX);
int y = MathHelper.floor_double(event.entity.posY - 0.20000000298023224D - event.entity.yOffset);
int z = MathHelper.floor_double(event.entity.posZ);
World world = FMLClientHandler.instance().getWorldClient();
Block block = world.getBlock(x, y, z);

if (MultiBlockSoundRegistry.multiBlockSounds.containsKey(block) && block.stepSound.getStepResourcePath().equals(event.name)) {
MultiBlockSoundContainer obj = MultiBlockSoundRegistry.multiBlockSounds.get(block);
String newSoundString = obj.getSound(world, x, y, z, event.name, MultiBlockSoundRegistry.BlockSoundType.WALK);
float volume = obj.getVolume(world, x, y, z, event.volume, MultiBlockSoundRegistry.BlockSoundType.WALK);
float pitch = obj.getPitch(world, x, y, z, event.volume, MultiBlockSoundRegistry.BlockSoundType.WALK);
if (newSoundString != null || volume != -1 || pitch != -1) {
if (newSoundString == null) newSoundString = event.name;
if (volume == -1) volume = event.volume;
if (pitch == -1) pitch = event.pitch;
event.entity.playSound(newSoundString + ignore_suffix, volume, pitch);
event.setCanceled(true);
}
} else if (ConfigSounds.newBlockSounds && ModSounds.soundAmethystBlock.getStepResourcePath().equals(event.name)) {
MutablePair<Float, Integer> pair = AMETHYST_CHIME_CACHE.get(event.entity);
if (pair == null) {
pair = new MutablePair<>(0.0F, 0);
}
float field_26997 = pair.getLeft();
int lastChimeAge = pair.getRight();
if (event.entity.ticksExisted >= lastChimeAge + 20) {
field_26997 = (float) ((double) field_26997 * Math.pow(0.996999979019165D, (double) (event.entity.ticksExisted - lastChimeAge)));
field_26997 = Math.min(1.0F, field_26997 + 0.07F);
float f = 0.5F + field_26997 * event.entity.worldObj.rand.nextFloat() * 1.2F;
float g = 0.1F + field_26997 * 1.2F;
event.entity.playSound(Reference.MCAssetVer + ":block.amethyst_block.chime", g, f);
lastChimeAge = event.entity.ticksExisted;
pair.setLeft(field_26997);
pair.setRight(lastChimeAge);
AMETHYST_CHIME_CACHE.put(event.entity, pair);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import ganymedes01.etfuturum.api.StrippedLogRegistry;
import ganymedes01.etfuturum.api.mappings.BlockAndMetadataMapping;
import ganymedes01.etfuturum.api.mappings.RawOreDropMapping;
import ganymedes01.etfuturum.blocks.BlockHoney;
import ganymedes01.etfuturum.blocks.BlockMagma;
import ganymedes01.etfuturum.blocks.BlockWitherRose;
import ganymedes01.etfuturum.client.sound.ModSounds;
Expand Down Expand Up @@ -74,11 +75,8 @@
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.event.entity.EntityStruckByLightningEvent;
import net.minecraftforge.event.entity.item.ItemTossEvent;
import net.minecraftforge.event.entity.living.EnderTeleportEvent;
import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
import net.minecraftforge.event.entity.living.*;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.event.entity.living.LivingSpawnEvent.SpecialSpawn;
import net.minecraftforge.event.entity.player.*;
import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
Expand All @@ -96,8 +94,8 @@ public class ServerEventHandler {

public static final ServerEventHandler INSTANCE = new ServerEventHandler();
public static HashSet<EntityPlayerMP> playersClosedContainers = new HashSet<>();
private static final HashMap<EntityPlayer, List<ItemStack>> armorTracker = new HashMap<>();
private static final Map<EntityPlayer, List<ItemStack>> armorTracker = new WeakHashMap<>();

private ServerEventHandler() {
}

Expand All @@ -106,13 +104,23 @@ public void onPlayerPickXP(PlayerPickupXpEvent event) {
ModEnchantments.onPlayerPickupXP(event);
}

@SubscribeEvent
public void livingJump(LivingEvent.LivingJumpEvent event) {
int x = MathHelper.floor_double(event.entity.posX);
int y = MathHelper.floor_double(event.entity.posY - 0.20000000298023224D - event.entity.yOffset);
int z = MathHelper.floor_double(event.entity.posZ);
if (event.entity.worldObj.getBlock(x, y, z) instanceof BlockHoney) {
event.entity.motionY *= .5D;
}
}

@SubscribeEvent
public void livingUpdate(LivingUpdateEvent event) {
EntityLivingBase entity = event.entityLiving;
if (entity.worldObj == null) return;

ModEnchantments.onLivingUpdate(entity);

double x = entity.posX;
double y = entity.posY;
double z = entity.posZ;
Expand Down Expand Up @@ -142,7 +150,7 @@ public void livingUpdate(LivingUpdateEvent event) {
ItemStack playerLeggings = player.getEquipmentInSlot(2);
ItemStack playerChestplate = player.getEquipmentInSlot(3);
ItemStack playerHelmet = player.getEquipmentInSlot(4);
armorTracker.put(player, Arrays.asList(new ItemStack[] {playerBoots, playerLeggings, playerChestplate, playerHelmet}));
armorTracker.put(player, Arrays.asList(playerBoots, playerLeggings, playerChestplate, playerHelmet));
} else {
List<ItemStack> armorList = armorTracker.get(player);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package ganymedes01.etfuturum.mixins.projectilecollidefix;

import net.minecraft.entity.Entity;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(EntityThrowable.class)
public abstract class MixinEntityThrowable extends Entity {
public MixinEntityThrowable(World p_i1582_1_) {
super(p_i1582_1_);
}

@Inject(method = "onUpdate", at = @At(value = "TAIL"))
public void checkCollide(CallbackInfo ci) {
func_145775_I();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private static void tweakRecipes() {

if (ConfigBlocksItems.replaceOldBoats && ConfigBlocksItems.enableNewBoats) {
removeFirstRecipeFor(Items.boat);
Items.boat.setTextureName("minecraft:oak_boat");
Items.boat.setTextureName("oak_boat");
Items.boat.setUnlocalizedName(Utils.getUnlocalisedName("oak_boat"));
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5533a34

Please sign in to comment.