mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 11:05:40 +00:00
1 parent
5e64ef9ecb
commit
4bfe562f14
6 files changed
+102
-28
No files matched your search
@@ -1,40 +1,61 @@
|
||||
--- a/net/minecraft/world/item/MobBucketItem.java
|
||||
+++ b/net/minecraft/world/item/MobBucketItem.java
|
||||
@@ -25,11 +_,24 @@
|
||||
@@ -23,13 +_,18 @@
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
|
||||
public class MobBucketItem extends BucketItem {
|
||||
private final EntityType<?> f_151134_;
|
||||
private final SoundEvent f_151135_;
|
||||
+ private final java.util.function.Supplier<? extends EntityType<?>> fishTypeSupplier;
|
||||
- private final EntityType<?> f_151134_;
|
||||
- private final SoundEvent f_151135_;
|
||||
+ private final java.util.function.Supplier<? extends EntityType<?>> entityTypeSupplier;
|
||||
+ private final java.util.function.Supplier<? extends SoundEvent> emptySoundSupplier;
|
||||
|
||||
+ @Deprecated
|
||||
public MobBucketItem(EntityType<?> p_151137_, Fluid p_151138_, SoundEvent p_151139_, Item.Properties p_151140_) {
|
||||
super(p_151138_, p_151140_);
|
||||
this.f_151134_ = p_151137_;
|
||||
this.f_151135_ = p_151139_;
|
||||
+ this.emptySoundSupplier = null;
|
||||
+ this.fishTypeSupplier = () -> p_151137_;
|
||||
- super(p_151138_, p_151140_);
|
||||
- this.f_151134_ = p_151137_;
|
||||
- this.f_151135_ = p_151139_;
|
||||
+ this(() -> p_151137_, () -> p_151138_, () -> p_151139_, p_151140_);
|
||||
+ }
|
||||
+
|
||||
+ public MobBucketItem(java.util.function.Supplier<? extends EntityType<?>> entitySupplier, java.util.function.Supplier<? extends Fluid> fluidSupplier, java.util.function.Supplier<? extends SoundEvent> soundSupplier, Item.Properties properties) {
|
||||
+ super(fluidSupplier, properties);
|
||||
+ this.f_151134_ = null;
|
||||
+ this.f_151135_ = null;
|
||||
+ this.emptySoundSupplier = soundSupplier;
|
||||
+ this.fishTypeSupplier = entitySupplier;
|
||||
+ this.entityTypeSupplier = entitySupplier;
|
||||
}
|
||||
|
||||
public void m_142131_(@Nullable Player p_151146_, Level p_151147_, ItemStack p_151148_, BlockPos p_151149_) {
|
||||
@@ -80,6 +_,14 @@
|
||||
p_151157_.add(mutablecomponent);
|
||||
@@ -41,11 +_,11 @@
|
||||
}
|
||||
|
||||
protected void m_7718_(@Nullable Player p_151151_, LevelAccessor p_151152_, BlockPos p_151153_) {
|
||||
- p_151152_.m_5594_(p_151151_, p_151153_, this.f_151135_, SoundSource.NEUTRAL, 1.0F, 1.0F);
|
||||
+ p_151152_.m_5594_(p_151151_, p_151153_, getEmptySound(), SoundSource.NEUTRAL, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
private void m_151141_(ServerLevel p_151142_, ItemStack p_151143_, BlockPos p_151144_) {
|
||||
- Entity entity = this.f_151134_.m_20592_(p_151142_, p_151143_, (Player)null, p_151144_, MobSpawnType.BUCKET, true, false);
|
||||
+ Entity entity = getFishType().m_20592_(p_151142_, p_151143_, (Player)null, p_151144_, MobSpawnType.BUCKET, true, false);
|
||||
if (entity instanceof Bucketable) {
|
||||
Bucketable bucketable = (Bucketable)entity;
|
||||
bucketable.m_142278_(p_151143_.m_41784_());
|
||||
@@ -55,7 +_,7 @@
|
||||
}
|
||||
|
||||
public void m_7373_(ItemStack p_151155_, @Nullable Level p_151156_, List<Component> p_151157_, TooltipFlag p_151158_) {
|
||||
- if (this.f_151134_ == EntityType.f_20489_) {
|
||||
+ if (getFishType() == EntityType.f_20489_) {
|
||||
CompoundTag compoundtag = p_151155_.m_41783_();
|
||||
if (compoundtag != null && compoundtag.m_128425_("BucketVariantTag", 3)) {
|
||||
int i = compoundtag.m_128451_("BucketVariantTag");
|
||||
@@ -81,5 +_,14 @@
|
||||
}
|
||||
}
|
||||
-
|
||||
|
||||
+ }
|
||||
+
|
||||
+ // Forge Start
|
||||
+ protected EntityType<?> getFishType() {
|
||||
+ return fishTypeSupplier.get();
|
||||
+ return entityTypeSupplier.get();
|
||||
+ }
|
||||
+
|
||||
+ protected SoundEvent getEmptySound() {
|
||||
|
||||
@@ -53,18 +53,6 @@ function initializeCoreMod() {
|
||||
return classNode;
|
||||
}
|
||||
},
|
||||
/*
|
||||
'mob_bucket_item': {
|
||||
'target': {
|
||||
'type': 'CLASS',
|
||||
'name': 'net.minecraft.world.item.MobBucketItem'
|
||||
},
|
||||
'transformer': function(classNode) {
|
||||
ASMAPI.redirectFieldToMethod(classNode, ASMAPI.mapField('f_41262_'), ASMAPI.mapMethod('getFishType')) // type - Not implemented
|
||||
return classNode;
|
||||
}
|
||||
},
|
||||
*/
|
||||
'itemstack': {
|
||||
'target': {
|
||||
'type': 'CLASS',
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2021.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.debug.item;
|
||||
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.MobBucketItem;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
@Mod(CustomMobBucketTest.MODID)
|
||||
public class CustomMobBucketTest
|
||||
{
|
||||
public static final String MODID = "custom_mob_bucket_test";
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||
|
||||
public static final boolean ENABLED = true;
|
||||
|
||||
public static final RegistryObject<Item> COW_BUCKET = ITEMS.register("cow_bucket", () -> new MobBucketItem(
|
||||
() -> EntityType.COW,
|
||||
() -> Fluids.WATER,
|
||||
() -> SoundEvents.BUCKET_EMPTY_FISH,
|
||||
(new Item.Properties()).stacksTo(1).tab(CreativeModeTab.TAB_MISC)));
|
||||
|
||||
public CustomMobBucketTest()
|
||||
{
|
||||
if (ENABLED)
|
||||
{
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
ITEMS.register(modEventBus);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -174,6 +174,8 @@ license="LGPL v2.1"
|
||||
modId="part_entity_test"
|
||||
[[mods]]
|
||||
modId="capabilities_test"
|
||||
[[mods]]
|
||||
modId="custom_mob_bucket_test"
|
||||
[[mods]]
|
||||
modId="custom_armor_model_test"
|
||||
[[mods]]
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "custom_mob_bucket_test:item/cow_bucket"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 6.2 KiB |
Reference in new issue
Block a user