Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add walk speed boost from Concrete (and remove some useless handlers) #106

Merged
merged 3 commits into from
Aug 25, 2021
Merged
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
28 changes: 10 additions & 18 deletions src/main/java/gregtech/common/EventHandlers.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
package gregtech.common;

import gregtech.api.GTValues;
import gregtech.common.blocks.BlockConcrete;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.init.MobEffects;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.config.Config;
import net.minecraftforge.common.config.ConfigManager;
import net.minecraft.util.MovementInput;
import net.minecraft.util.MovementInputFromOptions;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.event.entity.living.EnderTeleportEvent;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

@Mod.EventBusSubscriber
@Mod.EventBusSubscriber(modid = GTValues.MODID)
public class EventHandlers {

@SubscribeEvent
Expand All @@ -43,16 +47,4 @@ public static void onPlayerInteraction(PlayerInteractEvent.RightClickBlock event
}
}

@SubscribeEvent
public void onConfigChangedEvent(ConfigChangedEvent.OnConfigChangedEvent event) {
if (event.getModID().equals(GTValues.MODID)) {
ConfigManager.sync(GTValues.MODID, Config.Type.INSTANCE);
}
}

@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onBreakSpeed(PlayerEvent.BreakSpeed event) {
IBlockState state = event.getState();

}
}
27 changes: 27 additions & 0 deletions src/main/java/gregtech/common/blocks/BlockConcrete.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@

import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.MovementInput;
import net.minecraft.util.MovementInputFromOptions;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.gameevent.TickEvent;

import javax.annotation.Nonnull;

Expand Down Expand Up @@ -41,4 +51,21 @@ public String getName() {

}

private static MovementInput manualInputCheck;

@Override
public void onEntityWalk(World worldIn, BlockPos pos, Entity entityIn) {
if (manualInputCheck == null) {
manualInputCheck = new MovementInputFromOptions(Minecraft.getMinecraft().gameSettings);
}
IBlockState below = entityIn.getEntityWorld().getBlockState(new BlockPos(entityIn.posX, entityIn.posY - (1 / 16D), entityIn.posZ));
if (below.getBlock() instanceof BlockConcrete) {
manualInputCheck.updatePlayerMoveState();
if ((manualInputCheck.moveForward != 0 || manualInputCheck.moveStrafe != 0) && !entityIn.isInWater()) {
entityIn.motionX *= 1.6;
entityIn.motionZ *= 1.6;
}
}
}

}