Skip to content

Commit

Permalink
Merge branch '1.16.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelHillcox committed Sep 12, 2020
2 parents 1da8dcc + 6ab2bfd commit 4cbd2a8
Show file tree
Hide file tree
Showing 17 changed files with 257 additions and 77 deletions.
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Updated to 1.16 :+1:

## 1.16.1
### [1.4.1] - unreleased
### [1.4.2] - 2020-09-12
#### Added
- A new render for when the Item is in your hand thanks to [ItsTheBdoge](https://github.com/ItsTheBdoge) :heart:
- Added `hold shift` for full energy reading aka: `1M/1M FE` to `1,000,000/1,000,000 FE` It's nice! :D
- Updated Modification table textures a bit

#### Changed
- You can now use right click on TileEntities with the Gadget in your hand again. The blocker on this operation has been modified to only apply to things you might have in your offhand like torches. It's not perfect, but the perfect option requires a PR to Forge...

#### Fixed
- Fixed the Mining Gadget going into negative energy due to a issue with freezing upgrade

### [1.4.1] - 2020-08-21
#### Added
- Added a (disabled by default) key binding to open the Gadgets settings screen. (When enabled, it will disable the shift right click action)
- Added a Laser Beam preview to the Mining Gadget Visual Screen
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
#Mod Info
mod_version=1.4.1
mod_version=1.4.2
#Dependencies
forge_version=1.16.1-32.0.108
mcp_version=20200712-1.16.1
Expand Down
7 changes: 3 additions & 4 deletions src/generated/resources/.cache/cache
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
b7013e95c0f001eefb22e978563099d6af098f17 assets/mininggadgets/blockstates/minerslight.json
c2b2d34c116a3d6da9c62ce72021bd999590e3f2 assets/mininggadgets/blockstates/modificationtable.json
17f3e42d932950bb56cf0f43004c2badcef8cdc0 assets/mininggadgets/blockstates/renderblock.json
c439c311ccd1a6a67fddc2eb5db3f7fc0e0af1e0 assets/mininggadgets/blockstates/modificationtable.json
7b6864bd530b82aea92048d3b5208b716a30ae07 assets/mininggadgets/lang/en_us.json
96d2ffbcc3b9b76b312b16f381c382f8fc9165a3 assets/mininggadgets/models/block/lightremover.json
973359b4f13b4c70416dd8b3e68a3a4d8886f14f assets/mininggadgets/models/block/minerslight.json
a28c42b7d4a511d87ae88461f1845ed1b6bbc401 assets/mininggadgets/models/block/modificationtable.json
e0c9028f697d5a0ac2e9b3b73ba14c56b234648c assets/mininggadgets/models/block/modificationtable.json
30eb13c57d2684c6de2f1d2edfb7e535599b3a61 assets/mininggadgets/models/block/renderblock.json
c7cb89cde2f2fa96162238c434620e5c5093e1e0 assets/mininggadgets/models/item/minerslight.json
18734ba6f77297dd2b3ca6f3b8ef706a4456e52b assets/mininggadgets/models/item/modificationtable.json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
{
"variants": {
"": {
"facing=north": {
"model": "mininggadgets:block/modificationtable"
},
"facing=south": {
"model": "mininggadgets:block/modificationtable",
"y": 180
},
"facing=west": {
"model": "mininggadgets:block/modificationtable",
"y": 270
},
"facing=east": {
"model": "mininggadgets:block/modificationtable",
"y": 90
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
{
"parent": "minecraft:block/cube",
"parent": "minecraft:block/orientable_with_bottom",
"textures": {
"down": "mininggadgets:block/modificationtable_bottom",
"up": "mininggadgets:block/modificationtable_top",
"north": "mininggadgets:block/modificationtable_side",
"south": "mininggadgets:block/modificationtable_side",
"east": "mininggadgets:block/modificationtable_side",
"west": "mininggadgets:block/modificationtable_side",
"particle": "mininggadgets:block/modificationtable_side"
"side": "mininggadgets:block/modificationtable_side",
"front": "mininggadgets:block/modificationtable_front",
"bottom": "mininggadgets:block/modificationtable_bottom",
"top": "mininggadgets:block/modificationtable_top"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
package com.direwolf20.mininggadgets.client.events;

import com.direwolf20.mininggadgets.common.MiningGadgets;
import com.direwolf20.mininggadgets.common.items.ModItems;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.AbstractClientPlayerEntity;
import net.minecraft.client.renderer.FirstPersonRenderer;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.entity.PlayerRenderer;
import net.minecraft.client.renderer.model.ItemCameraTransforms;
import net.minecraft.util.Hand;
import net.minecraft.util.HandSide;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector3f;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.RenderHandEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

@Mod.EventBusSubscriber(modid = MiningGadgets.MOD_ID, value = Dist.CLIENT)
public class EventRenderGadget
{

@SubscribeEvent
static void renderGadget(RenderHandEvent event)
{
if (!ModItems.MININGGADGET.get().equals(event.getItemStack().getItem())) {
return;
}

Minecraft mc = Minecraft.getInstance();
MatrixStack matrixStackIn = event.getMatrixStack();
IRenderTypeBuffer buffer = event.getBuffers();

float swingProgress = event.getSwingProgress();
float equipProgress = event.getEquipProgress();
boolean rightHand = event.getHand() == Hand.MAIN_HAND ^ mc.player.getPrimaryHand() == HandSide.LEFT;

// renders arm
matrixStackIn.push();

float f = rightHand ? 1.0F : -1.0F;
float f1 = MathHelper.sqrt(swingProgress);
float f2 = -0.3F * MathHelper.sin(f1 * (float)Math.PI);
float f3 = 0.4F * MathHelper.sin(f1 * ((float)Math.PI * 2F));
float f4 = -0.4F * MathHelper.sin(swingProgress * (float)Math.PI);

matrixStackIn.translate(f * (f2 + 0.64000005F - .1f), f3 + -0.4F + equipProgress * -0.6F, f4 + -0.71999997F + .3f);
matrixStackIn.rotate(Vector3f.YP.rotationDegrees(f * 75.0F));

float f5 = MathHelper.sin(swingProgress * swingProgress * (float)Math.PI);
float f6 = MathHelper.sin(f1 * (float)Math.PI);

matrixStackIn.rotate(Vector3f.YP.rotationDegrees(f * f6 * 45.0F));
matrixStackIn.rotate(Vector3f.ZP.rotationDegrees(f * f5 * -20.0F));

AbstractClientPlayerEntity abstractclientplayerentity = mc.player;
mc.getTextureManager().bindTexture(abstractclientplayerentity.getLocationSkin());

matrixStackIn.translate(f * -1.0F, 3.6F, 3.5D);
matrixStackIn.rotate(Vector3f.ZP.rotationDegrees(f * 120.0F));
matrixStackIn.rotate(Vector3f.XP.rotationDegrees(200.0F));
matrixStackIn.rotate(Vector3f.YP.rotationDegrees(f * -135.0F));
matrixStackIn.translate(f * 5.6F, 0.0D, 0.0D);
matrixStackIn.rotate(Vector3f.YP.rotationDegrees(f * 55.0F));

PlayerRenderer playerrenderer = (PlayerRenderer) mc.getRenderManager().getRenderer(abstractclientplayerentity);
if (rightHand) {
playerrenderer.renderRightArm(matrixStackIn, buffer, event.getLight(), abstractclientplayerentity);
} else {
playerrenderer.renderLeftArm(matrixStackIn, buffer, event.getLight(), abstractclientplayerentity);
}

matrixStackIn.pop();

// renders gadget
matrixStackIn.push();
matrixStackIn.translate(f * (f2 + 0.64000005F - .1f), f3 + -0.4F + equipProgress * -0.6F, f4 + -0.71999997F - 0.1f);
matrixStackIn.rotate(Vector3f.YP.rotationDegrees(f * f6 * 70.0F));
matrixStackIn.rotate(Vector3f.ZP.rotationDegrees(f * f5 * -20.0F));
matrixStackIn.translate(rightHand ? .13f:-.1f, -.25f, -.35f);
matrixStackIn.scale(1.15f, 1.15f, 1.15f);

FirstPersonRenderer firstPersonRenderer = mc.getFirstPersonRenderer();
firstPersonRenderer.renderItemSide(abstractclientplayerentity,
event.getItemStack(),
rightHand
? ItemCameraTransforms.TransformType.FIRST_PERSON_RIGHT_HAND
: ItemCameraTransforms.TransformType.FIRST_PERSON_LEFT_HAND,
!rightHand,
event.getMatrixStack(),
event.getBuffers(),
event.getLight()
);
matrixStackIn.pop();

event.setCanceled(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
import com.direwolf20.mininggadgets.common.items.MiningGadget;
import com.direwolf20.mininggadgets.common.items.ModItems;
import com.direwolf20.mininggadgets.common.network.PacketHandler;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.client.util.InputMappings;
import net.minecraft.block.*;
import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.energy.CapabilityEnergy;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
Expand All @@ -27,7 +27,6 @@
import net.minecraftforge.fml.loading.FMLPaths;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.glfw.GLFW;

@Mod(MiningGadgets.MOD_ID)
public class MiningGadgets
Expand Down Expand Up @@ -69,8 +68,27 @@ public MiningGadgets() {
@SubscribeEvent
public void rightClickEvent(PlayerInteractEvent.RightClickBlock event) {
ItemStack stack = MiningGadget.getGadget(event.getPlayer());
if( stack.getItem() instanceof MiningGadget )
event.setCanceled(true);
if( stack.getItem() instanceof MiningGadget ) {
if (this.stackIsAnnoying(event.getPlayer().getHeldItemMainhand()) ||
this.stackIsAnnoying(event.getPlayer().getHeldItemOffhand())) {
event.setCanceled(true);
}
}
}

/**
* I've tried to identity annoying offhand items that can be placed whilst mining.
* I assume some level of logic so we assume that you'd have that item in your offhand
* whilst using the gadget.
*/
private boolean stackIsAnnoying(ItemStack stack) {
// This should never happen but I like casting safety
if (!(stack.getItem() instanceof BlockItem))
return false;

Block block = ((BlockItem) stack.getItem()).getBlock();
return block instanceof TorchBlock || block instanceof LanternBlock || block.equals(Blocks.GLOWSTONE)
|| block instanceof RedstoneLampBlock || block instanceof EndRodBlock;
}

private void setup(final FMLCommonSetupEvent event)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,25 @@
import com.direwolf20.mininggadgets.common.tiles.ModificationTableTileEntity;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.FurnaceBlock;
import net.minecraft.block.HorizontalBlock;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.inventory.InventoryHelper;
import net.minecraft.inventory.container.INamedContainerProvider;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.DirectionProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.common.ToolType;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fml.network.NetworkHooks;
import net.minecraftforge.items.CapabilityItemHandler;
Expand All @@ -23,10 +30,22 @@
import javax.annotation.Nullable;

public class ModificationTable extends Block {
public static DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING;

public ModificationTable() {
super(
Properties.create(Material.IRON).hardnessAndResistance(2.0f)
Properties.create(Material.IRON).hardnessAndResistance(2.0f).harvestTool(ToolType.PICKAXE)
);

this.setDefaultState(this.stateContainer.getBaseState().with(FACING, Direction.NORTH));
}

public BlockState getStateForPlacement(BlockItemUseContext context) {
return this.getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite());
}

protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
builder.add(FACING);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ public int extractEnergy(int maxExtract, boolean simulate) {

@Override
public int receiveEnergy(int maxReceive, boolean simulate) {
int amount = super.receiveEnergy(maxReceive, simulate);
int stored = this.getEnergyStored() + maxReceive;
if (stored < 0) {
return 0;
}

int amount = super.receiveEnergy(maxReceive, simulate);
if( !simulate )
stack.getOrCreateTag().putInt("energy", this.energy);

Expand Down
Loading

0 comments on commit 4cbd2a8

Please sign in to comment.