Skip to content

Commit

Permalink
Merge pull request Vivecraft#65 from fayer3/final-fixes
Browse files Browse the repository at this point in the history
Final fixes for 0.0.12
  • Loading branch information
fayer3 authored Oct 31, 2022
2 parents e8f05ff + 946ceae commit 353fb9d
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 229 deletions.
2 changes: 1 addition & 1 deletion common/src/main/java/org/vivecraft/CommonDataHolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public CommonDataHolder() {
String mcVersion = "";
String modVersion = "";
if (Xplat.isModLoadedSuccess()) {
String[] version = Xplat.getModVersion().split("-");
String[] version = Xplat.getModVersion().split("-", 2);
mcVersion = version[0];
modVersion = version[1];
}
Expand Down
196 changes: 0 additions & 196 deletions common/src/main/java/org/vivecraft/crafting/VivecraftCrafting.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public int rainZ() {

@Override
public Entity getRenderedEntity() {
return this.capturedEntity;
return this.renderedEntity;
}

@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Mth;floor(D)I", ordinal = 0), method = "renderSnowAndRain")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.vivecraft.mixin.world.item;

import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
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.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

@Mixin(Item.class)
public class ItemVRMixin {

@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;canEat(Z)Z", shift = At.Shift.BEFORE), method = "use", locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
private void alwaysAllowEasterEggEating(Level level, Player player, InteractionHand interactionHand, CallbackInfoReturnable<InteractionResultHolder<ItemStack>> cir, ItemStack itemStack) {
if (itemStack.getHoverName().getString().equals("EAT ME")) {
player.startUsingItem(interactionHand);
cir.setReturnValue(InteractionResultHolder.consume(itemStack));
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,14 @@ private static Item getVivecraftVanillaItem(JsonObject jsonObject, String resour
return Registry.ITEM.getOptional(new ResourceLocation(vanillaItem)).orElseThrow(() -> new JsonSyntaxException("Unknown item '" + vanillaItem + "'"));
}

@Group(name = "item to custom itemStack", min = 1, max = 1)
@Inject(method = "itemStackFromJson", at = @At(value = "INVOKE", target = "Lcom/google/gson/JsonObject;has(Ljava/lang/String;)Z", shift = At.Shift.BEFORE, remap = false), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true, expect = 0)
private static void customizeVanillaItemStackFabric(JsonObject jsonObject, CallbackInfoReturnable<ItemStack> cir, Item vanillaItem){
if (GsonHelper.getAsString(jsonObject, "item").startsWith("vivecraft")) {
cir.setReturnValue(customizeVanillaItemStack(jsonObject, vanillaItem));
}
}
@Group(name = "item to custom itemStack", min = 1, max = 1)
@Inject(method = "m_151274_", at = @At("HEAD"), cancellable = true, remap = false, expect = 0)
private static void customizeVanillaItemStackForge(JsonObject jsonObject, CallbackInfoReturnable<ItemStack> cir){
@Inject(method = "itemStackFromJson", at = @At("HEAD"), cancellable = true)
private static void customizeVanillaItemStackFabric(JsonObject jsonObject, CallbackInfoReturnable<ItemStack> cir){
if (GsonHelper.getAsString(jsonObject, "item").startsWith("vivecraft")) {
Item vanillaItem = getVivecraftVanillaItem(jsonObject, GsonHelper.getAsString(jsonObject, "item"));
cir.setReturnValue(customizeVanillaItemStack(jsonObject, vanillaItem));
}
}

private static ItemStack customizeVanillaItemStack(JsonObject jsonObject, Item vanillaItem){
if (jsonObject.has("data")) {
throw new JsonParseException("Disallowed data tag found");
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/resources/assets/vivecraft/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@
"vivecraft.options.shaderguirender.aftertranslucent": "Translucent",
"vivecraft.options.shaderguirender.beforetranslucentsolid": "Opaque",
"_comment_m5": "Option names",
"vivecraft.options.LOW_HEALTH_INDICATOR": "health indicator",
"vivecraft.options.LOW_HEALTH_INDICATOR": "Health Indicator",
"vivecraft.options.SHADER_GUI_RENDER": "Shaders GUI",
"_comment_m6": "Option tooltips",
"vivecraft.options.LOW_HEALTH_INDICATOR.tooltip": "Pulses the screen red, when at low health, to indicate your current health status",
Expand Down
1 change: 0 additions & 1 deletion common/src/main/resources/vivecraft.nonvr.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"world.entity.monster.EndermanFreezeWhenLookedAtMixin",

"world.item.CrossbowItemMixin",
"world.item.ItemsMixin",
"world.item.crafting.ShapedRecipeMixin"
],
"client": [
Expand Down
1 change: 1 addition & 0 deletions common/src/main/resources/vivecraft.vr.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"client.renderer.NoSodiumLevelRendererVRMixin",

"world.entity.vehicle.BoatMixin",
"world.item.ItemVRMixin",
"world.item.PotionItemVRMixin"
],
"server": [
Expand Down
8 changes: 7 additions & 1 deletion forge/src/main/java/org/vivecraft/forge/Vivecraft.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
package org.vivecraft.forge;

import net.minecraftforge.fml.IExtensionPoint;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.network.NetworkConstants;

@Mod(Vivecraft.MODID)
public class Vivecraft {
public static final String MODID = "vivecraft";

public Vivecraft() {

ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, ()-> new IExtensionPoint.DisplayTest(
()->NetworkConstants.IGNORESERVERONLY, // only needed on server, client is optional
(s,b)->true // any version is good
));
}
}

0 comments on commit 353fb9d

Please sign in to comment.