Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
made right clicking beeswax wax copper blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinsdar committed May 16, 2024
1 parent 03671bc commit a7d777a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.github.gregtechintergalactical.gtcore.GTCoreConfig;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.item.HoneycombItem;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.context.UseOnContext;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -14,7 +15,7 @@ public class MixinHoneycombItem {

@Inject(method = "useOn", at = @At("HEAD"), cancellable = true)
private void injectUseOn(UseOnContext context, CallbackInfoReturnable<InteractionResult> cir){
if (GTCoreConfig.HONEYCOMB_REPLACEMENT.get()){
if (GTCoreConfig.HONEYCOMB_REPLACEMENT.get() && context.getItemInHand().getItem() == Items.HONEYCOMB){
cir.setReturnValue(InteractionResult.PASS);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
import muramasa.antimatter.event.fabric.LoaderEvents;
import muramasa.antimatter.event.fabric.ProviderEvents;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.player.UseBlockCallback;
import net.fabricmc.fabric.api.event.player.UseItemCallback;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.context.UseOnContext;

import static io.github.gregtechintergalactical.gtcore.data.GTCoreMaterials.Beeswax;
import static muramasa.antimatter.data.AntimatterMaterialTypes.DUST;

//initializer class for non antimatter related stuff
public class GTCoreFabric implements ModInitializer {
Expand All @@ -13,5 +21,11 @@ public void onInitialize() {
ProviderEvents.PROVIDERS.register(GTCore::onProviders);
CraftingEvents.CRAFTING.register(GTCore::onCrafting);
LoaderEvents.LOADER.register(GTCore::registerRecipeLoaders);
UseBlockCallback.EVENT.register((player, level, interactionHand, hitResult) -> {
if (player.getItemInHand(interactionHand).is(DUST.getMaterialTag(Beeswax))){
return Items.HONEYCOMB.useOn(new UseOnContext(player, interactionHand, hitResult));
}
return InteractionResult.PASS;
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,26 @@
import muramasa.antimatter.event.forge.AntimatterLoaderEvent;
import muramasa.antimatter.event.forge.AntimatterProvidersEvent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.levelgen.feature.foliageplacers.FoliagePlacerType;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.event.entity.item.ItemEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.world.ChunkWatchEvent;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;

import static io.github.gregtechintergalactical.gtcore.data.GTCoreMaterials.Beeswax;
import static muramasa.antimatter.data.AntimatterMaterialTypes.DUST;

// The value here should match an entry in the META-INF/mods.toml file
@Mod(GTCore.ID)
public class GTCoreForge extends GTCore {
Expand All @@ -29,6 +37,7 @@ public GTCoreForge(){
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onCraftingEvent);
MinecraftForge.EVENT_BUS.<AntimatterLoaderEvent>addListener(GTCoreForge::registerRecipeLoaders);
MinecraftForge.EVENT_BUS.addListener(this::onChunkWatch);
MinecraftForge.EVENT_BUS.addListener(this::onItemUse);
FMLJavaModLoadingContext.get().getModEventBus().addGenericListener(FoliagePlacerType.class, this::onRegistration);
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> {
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientSetup);
Expand All @@ -45,6 +54,13 @@ private void onChunkWatch(ChunkWatchEvent.Watch event){
});*/
}

private void onItemUse(PlayerInteractEvent.RightClickBlock event){
if (event.getPlayer().getItemInHand(event.getHand()).is(DUST.getMaterialTag(Beeswax))){
event.setCancellationResult(Items.HONEYCOMB.useOn(new UseOnContext(event.getPlayer(), event.getHand(), event.getHitVec())));
event.setCanceled(true);
}
}

@OnlyIn(Dist.CLIENT)
private void clientSetup(FMLClientSetupEvent event){
ClientHandler.init();
Expand Down

0 comments on commit a7d777a

Please sign in to comment.